Zishu example, the routine of this question makes me have a long knowledge. We have never used cctype or stringstream. It is very practical and worth learning.
# Include <cctype> Functions
In C ++, it should be # include <cctype> In C, it should be # include <ctype. h> The following are common functions in the character function library:
| Function Name |
Return Value |
| Isalnum () |
If the parameter is a letter or number, this function returns true. |
| Isalpha () |
If the parameter is a letter, this function returns true |
| Isblank () |
If the parameter is a space or horizontal tab, this function returns true. |
| Iscntrl () |
If the parameter is a control character, this function returns true |
| Isdigit () |
If the parameter is a number (0 ~ 9). This function returns true. |
| Isgraph () |
If the parameter is a print character other than space, this function returns true |
| Islower () |
If the parameter is a lowercase letter, this function returns true. |
| Isprint () |
If the parameter is a print character (including spaces), this function returns true |
| Ispunct () |
If the parameter is a punctuation mark, this function returns true. |
| Isspace () |
If the parameter is a standard blank character, such as space, paper feed, line feed, and carriage return , Horizontal or vertical tab, this function returns true |
| Isupper () |
If the parameter is an uppercase letter, this function returns true. |
| Isxdigit () |
If the parameter is a hexadecimal number, that is, 0 ~ 9. ~ F, ~ F. This function returns true. |
| Tolower () |
If the parameter is an uppercase character, it is returned in lower case; otherwise, this parameter is returned. |
| Toupper () |
If the parameter is a lowercase letter, it is returned in uppercase; otherwise, this parameter is returned. |
|
# Include <iostream> # include <cstdio> # include <cstdlib> # include <cstring> # include <cmath> # include <map> # include <set> # include <vector> # include <algorithm> # include <stack> # include <queue> # include <cctype> # include <sstream> using namespace STD; # define INF 1000000000 # define EPS 1e-8 # define PII pair <int, int> # define ll long int # define maxn 100009 string S, Buf; set <string> dict; int main () {// freopen ("in.txt", "r", stdin); // freopen ("out.txt", "W", stdout ); while (CIN> S) {int Len = S. length (); stringstream SS; For (INT I = 0; I <Len; I ++) {If (isalpha (s [I]) s [I] = tolower (s [I]); else s [I] = '';} SS <s;
/* You can also use ss. STR (s). If you clear SS content, use ss. STR (""). Note ss. STR (s) overwrites the original content in SS, while SS <s adds S */while (SS> BUF) // No space will be passed {dict. insert (BUF) ;}}for (set <string >:: iterator it = dict. begin (); it! = Dict. end (); It ++) // note that it cannot be written <dict. end (), only equal and unequal cout <* It <Endl; return 0 ;}
Uva10815 (Set Application)