描述 | |
---|---|
知识点 | 查找 |
运行时间限制 | 10M |
内存限制 | 128 |
输入 | 先输入字典中单词的个数,再输入n个单词作为字典单词。 |
输出 | 根据输入,输出查找到的兄弟单词的个数 输出指定的第n个兄弟单词 |
样例输入 | 3 abc bca cab abc 1 |
样例输出 | 2 bca |
代码在vs2010中调试可运行,且能输出正确的答案,但是oj平台提示格式错误,不知道什么原因。
修改输出格式后得分为120分。 不得不吐糟一下这oj平台的输出格式检测啊。。。。
/**************
查找兄弟单词
****************/
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std; typedef set
stset; bool isBro(const stset::iterator it,string word); int main() { int n; //number of words int o_num, bro_num; string word,Dword; stset Wdset; vector
Brovec; cin>>n; while(n) { cin>>word; Wdset.insert(word); n--; } cin>>Dword; //input the dest word cin>>o_num; //output number of brother word stset::iterator it; for(it=Wdset.begin();it!=Wdset.end();++it) { if(isBro(it,Dword)) { Brovec.push_back(*it); } } bro_num=Brovec.size(); if(bro_num>=o_num) // cout<
<<" "<
<