标题:求字符串的max
取消只看楼主
好聚好散
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:138
专家分:123
注 册:2012-12-4
结帖率:77.42%
已结贴  问题点数:20 回复次数:2 
求字符串的max
/*从键盘输入3个可带空格的字符串(约定:字符数≤127字节),输出最大的字符串。编程可用素材:
printf("Please input the first string:\t")、printf("Please input the second string:\t")、
printf("Please input the third string:\t")、printf("\n最大字符串是:…。
  程序的运行效果应类似地如图1所示,图1中的C program、hello、god save me是从键盘输入的内容。
Please input the first string:  C program
Please input the second string: hello
Please input the third string:  god save me

最大字符串是:hello
*/

#include<stdio.h>

#include<string.h>

int main(void)

{
    char s1[128], s2[128], s3[128], ss[128];
   
    printf("Please input the first string:\t");
    gets(s1);
    printf("Please input the second string:\t");
    gets(s2);
    printf("Please input the third string:\t");
    gets(s3);

    ss[128] = s1[128];
    if (strcmp(ss,s2)<0)
    {
        ss[128] = s2[128];
    }
    if(strcmp(ss,s3)<0)
    {
        ss[128] = s3[128];
    }

printf("\n最大字符串是:%s\n", ss);
return 0;
}
求高手  为什么运行出不来呢  真心解释
搜索更多相关主题的帖子: 最大的 second 字符串 hello 
2012-12-05 22:06
好聚好散
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:138
专家分:123
注 册:2012-12-4
得分:0 
回复 2楼 azzbcc
为什么那样不可以嘛

无节操,无真相
2012-12-05 23:06
好聚好散
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:138
专家分:123
注 册:2012-12-4
得分:0 
OK   真心懂了  O(∩_∩)O谢谢

无节操,无真相
2012-12-06 13:02



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-389797-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018028 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved