

#include<set>//此种解法dsds# dsds是可以输入的,但是HDOJ也通过了。下面的解法解决了此问题。
#include<string>
#include<iostream>
using namespace std;
int main()
{
char c='0';
string s;
set<string> word;
while((c=getchar())!='#')//注意getchar()和cin 的区别
{
s="";
while(c!=' '&&c!='\n')
{
s+=c;
c=getchar();
}
if(s.length()) word.insert(s);
if(c=='\n')
{
cout<<word.size()<<"\n";
word.clear();
}
}
return 0;
}#include<set>
#include<string>
#include<iostream>
using namespace std;
int main()
{
char c='0';
string s;
set<string> word;
while((c=getchar())!='#')
{
s="";
while(c!=' '&&c!='\n'&&c!='#')
{
s+=c;
c=getchar();
}
if(c=='#') return 0;
if(s.length()) word.insert(s);
if(c=='\n')
{
cout<<word.size()<<"\n";
word.clear();
}
}
return 0;
}
相关文章:
-
2021-12-27
-
2022-12-23
-
2022-12-23
-
2022-12-23
-
2022-12-23
-
2022-12-23
-
2022-12-23
猜你喜欢
-
2021-11-14
-
2022-12-23
-
2021-06-09
-
2021-09-27
-
2021-10-30
-
2021-08-31
-
2021-12-07
相关资源
-
下载
2022-12-07
-
下载
2022-12-14
-
下载
2023-01-15