zoukankan      html  css  js  c++  java
  • Andy's First Dictionary---set,stringstream

    https://cn.vjudge.net/contest/177260#problem/C

    stringstream :https://blog.csdn.net/xw20084898/article/details/21939811

    学习:http://www.cnblogs.com/yjlblog/p/6947747.html

    注意set的*

     1 #include<stdio.h>
     2 #include<string.h>
     3 #include<math.h>
     4 #include<iostream>
     5 #include<stdlib.h>
     6 #include<algorithm>
     7 #include<queue>
     8 #include<vector>
     9 #include<string>
    10 #include<set>
    11 #include<cctype>
    12 #include<sstream>
    13 #define mem(a) memset(a,0,sizeof(a))
    14 #define LL long long
    15 using namespace std;
    16 const long long  N=1e9+5;
    17 set<string>ans;
    18 int main()
    19 {
    20   //用set,元素只能出现一次,并且插入可以从小到大排序
    21    string s,tmp;
    22    while(cin>>s)
    23    {
    24        for(size_t i=0;i<s.size();i++) //size_t一般用来表示一种计数
    25        if(isalpha(s[i])) //小写字母返回2,大写字母返回1
    26        s[i]=tolower(s[i]); //变小写
    27        else s[i]=' ';
    28      stringstream ss(s);
    29      while(ss>>tmp) ans.insert(tmp); //向tmp中写入值,传值<<,
    30    }
    31    for(set<string>::iterator it=ans.begin();it!=ans.end();it++)
    32    {
    33        cout<<*it<<endl;
    34 /*set不是数组 只能通过迭代器(iterator)把里面的元素倒出来
    35 迭代器相当于是指针 扫描的是地址 因此输出的时候需要用*variation*/
    36    }
    37     return 0;
    38 }
    39 //输出时在空行输入 ctrl+z+回车
    View Code
  • 相关阅读:
    信号的调制
    是否产生latch
    带通采样定理
    傅里叶变换
    信号与傅里叶(下)
    滤波器的相位和信号的时延
    信号与傅里叶级数
    阅读应该是主动的
    Matlab笔记—函数
    网络搭建---IP地址的设置及ping的使用
  • 原文地址:https://www.cnblogs.com/XXrll/p/10295421.html
Copyright © 2011-2022 走看看