怎么在c++中输入一串字符啊

一道简单的acm题我还是不会

A. Word Reversal

Time Limit: 1.0 Seconds Memory Limit: 65536K Multiple test files

For each list of words, output a line with each word reversed without changing the order of the words.

Input
You will be given a number of test cases. The first line contains a positive integer indicating the number of cases to follow. Each case is given on a line containing a list of words separated by one space, and each word contains only uppercase and lowercase letters.

Output
For each test case, print the output on one line.

Sample Input
3
I am happy today
To be or not to be
I want to win the practice contest

Sample Output
I ma yppah yadot
oT eb ro ton ot eb
I tnaw ot niw eht ecitcarp tsetnoc

c++中输入一串字符的函数有多种:

    C标准函数,存储字符到字符数组中:

    char str[100];

    scanf("%s", str ) ; //读入一串字符,不能包括空格

    gets(str); //输入一行字符,可以有空格,以回车键结束

    C++函数,可以存储到字符数组,也可以存储到string类对象中:

    string str;

    cin >> str ; //读入一串字符,不能包括空格

    getline(cin,str ); //输入一行字符,可以有空格,以回车键结束

温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-11-21
读取成C类型字符串,const_cast去掉const属性,编写方法倒置i到j之间字符,利用空格所在位置,调用这个方法,倒置所有单词,输出C类型字符串来自:求助得到的回答
第1个回答  2012-11-21
先分割字符串,然后每个字符串从后往前输出
第2个回答  2012-11-17
cin>>你的字符串的名字;如:
string str;
则cin>>str;
第3个回答  2012-11-17
char a[10]
cin>>a;
相似回答