解题思路:
注意事项:
最后一个单词要考虑到
参考代码:#include <bits/stdc++.h>
using namespace std;
map<string,int> mp;
int main()
{ string str;
getline(cin,str);
string temp="";
for(int i=0;i<str.length();i++)
{ if(str[i]!=' ')
{ temp+=str[i];
}
else
{// cout<<temp<<endl;
mp[temp]++;
temp="";
}
}
mp[temp]++;//最后一个单词
printf("%d",mp.size());
}
0.0分
1 人评分
汽水瓶 (C语言代码)浏览:698 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:629 |
C二级辅导-同因查找 (C语言代码)浏览:580 |
2006年春浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:808 |
不容易系列 (C语言代码)浏览:665 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:520 |
【简单计算】 (C语言代码)浏览:622 |
C语言程序设计教程(第三版)课后习题6.3 (C++代码)浏览:954 |
IP判断 (C语言描述,蓝桥杯)浏览:1095 |
数字游戏 (C++代码)浏览:1180 |