| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付赛孚耐:软件保护加密专家
身份认证令牌USB KEY   
共有 210 人关注过本帖
标题:一个简单c++问题-->小天狼星转移
收藏  订阅  推荐  打印 
lfzhang
Rank: 1
等级:新手上路
帖子:3
积分:130
注册:2006-11-8
一个简单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-8 14:10
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.078292 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved