| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2009 人关注过本帖
标题:郁闷!这道题目怎么编?
只看楼主 加入收藏
woodhead
Rank: 3Rank: 3
等 级:新手上路
威 望:9
帖 子:1124
专家分:0
注 册:2005-7-18
收藏
得分:0 

#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;

int main()
{
vector<string> text; //hold all word
string word;
int max=0;

cout<<"please input text :"<<endl;
//read line......

while(1)
{
cin>>word;
if(max < word.size())
max = word.size();
text.push_back(word);

if(cin.get()=='\n') break;
}

//output.............

int size=text.size();
cout<<"longest word : \n";
for(int i=0; i<size; i++)
if(text[i].size()==max)
cout<<'\t'<<text[i]<<'\n';
cout<<"lengh : "<<max<<endl;

system("pause");
return 0;
}

把我前面的简化了一下


2006-01-11 16:50
快速回复:郁闷!这道题目怎么编?
数据加载中...
 
   



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

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