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 }

 

 

posted on 2018-06-28 10:44  孙悟空son_ku_kong  阅读(131)  评论(0编辑  收藏  举报

导航