C语言学习(12)

 1 //比较两个字符串
 2 #include<stdio.h>
 3 #include<string.h>
 4 int main(){
 5     char s1[100],s2[100];
 6     int i;
 7     printf("请输入字符串1\n");
 8     gets(s1);
 9     printf("请输入字符串2\n");
10     gets(s2);
11     if(strcmp(s1,s2)>0){
12         printf("字符串1大于字符串2\n");
13     }else if(strcmp(s1,s2)==0){
14         printf("字符串1等于字符串2");
15     }else{
16         printf("字符串2大于字符串1\n");
17     }
18     return 0;
19 }

猜你喜欢

转载自www.cnblogs.com/Tobi/p/9237524.html