• 单词数


    #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
    //                        ____/`---'\____
    //                      .'  |     |//  `.
    //                     /  |||  :  |||//  
    //                    /  _||||| -:- |||||-  
    //                    |   | \  -  /// |   |
    //                    | \_|  ''---/''  |   |
    //                      .-\__  `-`  ___/-. /
    //                  ___`. .'  /--.--  `. . __
    //               ."" '<  `.___\_<|>_/___.'  >'"".
    //              | | :  `- \`.;` _ /`;.`/ - ` : | |
    //                 `-.   \_ __ /__ _/   .-` /  /
    //         ======`-.____`-.___\_____/___.-`____.-'======
    //                            `=---='
    //        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    //
    

      

  • 相关阅读:
    冒泡排序
    pdo 单例类
    php 事物处理
    支付宝支付
    反向代理和负载均衡
    execl导出
    网络层
    OSI 7层 TCP/IP 4层 综合5层
    面试总结
    CMD AMD
  • 原文地址:https://www.cnblogs.com/akpower/p/11768781.html
Copyright © 2020-2023  润新知