怎么在c++中输入一串字符啊
一道简单的acm题我还是不会A.WordReversalTimeLimit:1.0SecondsMemoryLimit:65536KMultipletestfilesFo...
一道简单的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 展开
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 展开
6个回答
展开全部
c++中输入一串字符的函数有多种:
C标准函数,存储字符到字符数组中:
char str[100];
scanf("%s", str ) ; //读入一串字符,不能包括空格
gets(str); //输入一行字符,可以有空格,以回车键结束
C++函数,可以存储到字符数组,也可以存储到string类对象中:
string str;
cin >> str ; //读入一串字符,不能包括空格
getline(cin,str ); //输入一行字符,可以有空格,以回车键结束
展开全部
读取成C类型字符串,const_cast去掉const属性,编写方法倒置i到j之间字符,利用空格所在位置,调用这个方法,倒置所有单词,输出C类型字符串
来自:求助得到的回答
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
先分割字符串,然后每个字符串从后往前输出
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
cin>>你的字符串的名字;如:
string str;
则cin>>str;
string str;
则cin>>str;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
char a[10]
cin>>a;
cin>>a;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询