| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 492 人关注过本帖
标题:一个简单c++问题-->小天狼星转移
只看楼主 加入收藏
lfzhang
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-11-8
收藏
 问题点数:0 回复次数:0 
一个简单c++问题-->小天狼星转移

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
bool isShorter(const string &s1,const string &s2)
{
return s1.size()<s2.size();
}
bool GT6(const string &s)
{
return s.size()>=6;
}
string make_plural(size_t n,const string &word,const string &ending)
{
return(n==1)? word:word + ending;
}

int main()
{
// TODO: 请用您自己的代码替换下面的示例代码。
vector<string> words;
string word;
while(cin>>word)
{
words.push_back(word);

}
sort(words.begin(),words.end());
vector<string>::iterator it =words.begin();
for(;it!=words.end();++it)
cout<<*it<<endl;
vector<string>::iterator end_unique=unique(words.begin(),words.end());
words.erase(end_unique,words.end());
stable_sort(words.begin(),words.end(),isShorter);
vector<string>::size_type wc =count_if(words.begin(),words.end(),GT6);
cout<<wc<<""<< make_plural(wc,"word","s")<<"6 character or longer"<<endl;
return 0;
}
能运行但是为什么没有输出结果啊 我不停的输入单词 可是没有运行的结果啊

搜索更多相关主题的帖子: 小天狼星 
2006-11-08 14:10
快速回复:一个简单c++问题-->小天狼星转移
数据加载中...
 
   



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

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