UVA 10815【set【附帶cctype

c++中應該是#include <cctype>

以下爲字符函數庫中常用的函數:

函數名稱 返回值
isalnum() 如果參數是字母數字,即字母或數字,該函數返回true
isalpha() 如果參數是字母,該函數返回真
isblank() 如果參數是空格或水平製表符,該函數返回true
iscntrl() 如果參數是控制字符,該函數返回true
isdigit() 如果參數是數字(0~9),該函數返回true
isgraph() 如果參數是除空格之外的打印字符,該函數返回true
islower() 如果參數是小寫字母,該函數返回true
isprint() 如果參數是打印字符(包括空格),該函數返回true
ispunct() 如果參數是標點符號,該函數返回true
isspace()

如果參數是標準空白字符,如空格、進紙、換行符、回車

、水平製表符或者垂直製表符,該函數返回true

isupper() 如果參數是大寫字母,該函數返回true
isxdigit() 如果參數是十六進制的數字,即0~9、a~f、A~F,該函數返回true
tolower() 如果參數是大寫字符,則返回其小寫,否則返回該參數
toupper()

如果參數是小寫字母,則返回其大寫,否則返回該參數

 set的用法

https://blog.csdn.net/chaiwenjun000/article/details/50561775(遍歷)

www.cnblogs.com/BeyondAnyTime/archive/2012/08/13/2636375.html

#include "iostream"
#include "algorithm"
#include "cstring"
#include "sstream"
#include "set"
using namespace std;
set<string>s;
int main(){
    string s1,buff;
    while(cin>>s1){
    for(int i=0;i<s1.size();i++){
        if(isalpha(s1[i]))
            s1[i]=tolower(s1[i]);
        else s1[i]=' ';
    }
        stringstream ss(s1);
        while(ss>>buff)
            s.insert(buff);
    }
    for(set<string>::iterator it=s.begin();it!=s.end();it++)
     cout<<*it<<endl;
   
    return 0;
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章