- #include<stdio.h>
- #include<iostream>
- #include<algorithm>
- #include<string.h>
- #include<vector>
- #include<cmath>
- #include<string>
- #include<map>
- #include<queue>
- #include<set>
- using namespace std;
- typedef long long ll;
- set<string> m;
- int main(){
- string s,a;
- ll cnt=0;
- // 注意一定要用 getline 读入, 可以读取的空格
- while(getline(cin,s)&&s[0]!='#'){
- m.clear();
- a="";
- ll len=s.length();
- for(ll i=0;i<len;i++){
- if(s[i]!=' '){
- a+=s[i];// 字符串的累加
- }
- else {
- if(a!=""){
- m.insert(a);// 入集合
- }
- a="";
- }
- }
- if(a!=""){
- m.insert(a);
- }
- cout<<m.size()<<endl;// 集合会自动去重, 输出元素个数
- }
- return 0;
- }
- // /\ | / |**,
- // / \ | / | // / \ |/ | / _____ ____ | /
- // /------\ |\ |__/ / \ \ /\ // \ | /
- // / \ | \ | / \ \ / \ //______\ |/
- // / \ | \ | \ / \ / \ / \ |
- // / \ | \ | \_____/ \/ \/ \_____ |
- /**
- * ┏┓ ┏┓
- * ┏┛┗━━━━━━━┛┗━━━┓
- * ┃ ┃
- * ┃ ━ ┃
- * ┃ > < ┃
- * ┃ ┃
- * ┃... ⌒ ... ┃
- * ┃ ┃
- * ┗━┓ ┏━┛
- * ┃ ┃ Code is far away from bug with the animal protecting
- * ┃ ┃ 神兽保佑, 代码无 bug
- * ┃ ┃
- * ┃ ┃
- * ┃ ┃
- * ┃ ┃
- * ┃ ┗━━━┓
- * ┃ ┣┓
- * ┃ ┏┛
- * ┗┓┓┏━┳┓┏┛
- * ┃┫┫ ┃┫┫
- * ┗┻┛ ┗┻┛
- */
- // warm heart, wagging tail,and a smile just for you!
- //
- // _ooOoo_
- // o8888888o
- // 88"."88
- // (| -_- |)
- // O\ = /O
- // ____/`---'\____
- // .' \| |// `.
- // / \||| : |||// // / _||||| -:- |||||- // | | \\ - /// | |
- // | \_| ''\---/'' | |
- // \ .-\__ `-` ___/-. /
- // ___`. .' /--.--\ `. . __
- // .""'<`.___\_<|>_/___.'>'"".
- // | | : `- \`.;`\ _ /`;.`/ - ` : | |
- // \ \ `-. \_ __\ /__ _/ .-` //
- // ======`-.____`-.___\_____/___.-`____.-'======
- // `=---='
- // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- //
单词数
来源: http://www.bubuko.com/infodetail-3265817.html