找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3840|回復: 0
打印 上一主題 下一主題
收起左側

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

[復制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:71259 發(fā)表于 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. }
復制代碼


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復 返回頂部 返回列表