找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4070|回复: 0
收起左侧

c++ 3个字符串,找出其中的最大者

[复制链接]
ID:71259 发表于 2014-12-30 15:51 | 显示全部楼层 |阅读模式
  1. #include<iostream>
  2. #include<string.h>
  3. using namespace std;
  4. void main()
  5. {
  6. char string[20];
  7. char str[3][20];
  8. int i;
  9. cout<<"请输入个字符串"<<endl;
  10. for(i=0;i<3;i++)
  11.   gets(str[i]);
  12. if(strcmp(str[0],str[1])>0)
  13.   strcpy(string,str[0]);
  14. else strcpy(string,str[1]);
  15. if(strcmp(str[2],string)>0)
  16.   strcpy(string,str[2]);
  17. cout<<"最大的那个字符串是:"<<string<<endl;
  18. }
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表