主题:请教各位高手,这个程序哪里错了?请帮我纠正一下
题目:比较链串s1和s2链串的大小,若s1<s2,返回-1,若s1=s2,返回0;若s1>s2则返回1.
#include <iostream.h>
struct node {
char data;
node *s1,*s2,*next;
};
class string
{
public:
strcmp(node *,node*);
private:
char data;
node *pa,*pb,*next;
};
string:: strcmp (node *s1,node *s2)
{
node *pa=s1,*pb=s2;
while (pa!=NULL && pb!=NULL)
if (pa-> data==pb->data)
{pa=pa->next;
pb=pb->next;
}
else if (pa-> data<pb->data)
return -1;
else return 1;
if (pa==NULL)
if (pb!=NULL)
return -1;
else return 0;
else return 1;
}
int main ()
{
char s1[10]="abcdefg";
char s2[10]="abcge";
string.strcmp(node *s1,*s2);
return 0;
}
#include <iostream.h>
struct node {
char data;
node *s1,*s2,*next;
};
class string
{
public:
strcmp(node *,node*);
private:
char data;
node *pa,*pb,*next;
};
string:: strcmp (node *s1,node *s2)
{
node *pa=s1,*pb=s2;
while (pa!=NULL && pb!=NULL)
if (pa-> data==pb->data)
{pa=pa->next;
pb=pb->next;
}
else if (pa-> data<pb->data)
return -1;
else return 1;
if (pa==NULL)
if (pb!=NULL)
return -1;
else return 0;
else return 1;
}
int main ()
{
char s1[10]="abcdefg";
char s2[10]="abcge";
string.strcmp(node *s1,*s2);
return 0;
}