C语言问题:不用strcmp函数比较两个字符串的大小
来源:百度知道 编辑:UC知道 时间:2024/06/15 13:15:56
#include<stdio.h>
main()
{ int i=0;
char a[100],b[100];
gets(a);gets(b);
while(a[i] == b[i]&&a[i]!='\0')i++;
if (a[i] == '\0')
printf("The 2 strings are the same.");
else
printf("The 2 strings are different.");
}
这个程序只能比较两个字符串是否相同 如果改这个程序 使它能比较出字符串a>b a<b a=b 三种情况呢?
main()
{ int i=0;
char a[100],b[100];
gets(a);gets(b);
while(a[i] == b[i]&&a[i]!='\0')i++;
if (a[i] == '\0')
printf("The 2 strings are the same.");
else
printf("The 2 strings are different.");
}
这个程序只能比较两个字符串是否相同 如果改这个程序 使它能比较出字符串a>b a<b a=b 三种情况呢?
#include<stdio.h>
int main()
{
int i=0;
char a[100],b[100];
gets(a);gets(b);
while(a[i] == b[i]&&a[i]!='\0')i++;
if (a[i] == '\0'&&b[i]=='\0')
printf("The 2 strings are the same. a =b\n");
else {
if(a[i] > b[i])
printf("The 2 strings are different. a > b\n");
else
printf("The 2 strings are different. a < b\n");
}
}
做减法可以比较啊
C程序问题(strcmp 的怪现像)
C语言中strcmp是什么意思?有什么功能和作用?
c语言问题,高手帮下忙吧~?type mismatch in parameter 's1' in call to 'strcmp'
strcmp的问题???
C语言编程:用自定义函数实现字符串处理函数strcat、 strcpy、strcmp、strlen和
C语言编程-用数组方法编写函数strcmp,比较两个字符串的大小。
(c语言数组的!)比较两个字符串的大小。(不可以用strcmp做)
编C语言程序:用自定义函数实现字符串处理函数strcat、 strcpy、strcmp、strlen和strlwr的功能
求教C++strcmp函数的用法???
C语言 为什么不用指针