"尚学堂杯"哈尔滨理工大学第七届程序设计竞赛 F.Final Ugly English(字符串处理)

F.Final Ugly English
Time Limit: 1000 MS Memory Limit: 32768 K
Total Submit: 2074 (405 users) Total Accepted: 294 (291 users) Special Judge: No
Description

ACM twist-toy encountered such a problem in the work, this article, to ensure that this article only lowercase

letters and spaces, please send the articles in each word inverted output, such as "hello world this is an 

competition". You should output "olleh dlrow siht si na noititepmoc".

Input

A group of data, each line of data input from the lower case letters and spaces of the article,

the length of not more than one thousand

Output
Output a line for each word after the reversal of the article.
Sample Input
hello world this is an competition
Sample Output
olleh dlrow siht si na noititepmoc


思路:这里get 到的就是reverse()函数的字符串翻转。但是在我自己打代码的时候发现了一个比较好玩的两边对称翻转,另附代码2上;

注:char 类型的字符串整行输入是gets(a);但是string 类型的整行输入是getline(cin,a);



#include
#include
#include
#include
using namespace std;
#define maxx 1010
const int mod=10007;
int broken[maxx];
int num[maxx];
int main()
{
  string a;
   while(getline(cin,a))
   {
       int len=a.length();
       for(int i=0;i


代码2:


#include
#include
#include
#include
using namespace std;
#define maxx 1010
const int mod=10007;
int broken[maxx];
int num[maxx];
int main()
{
  string a;
   while(getline(cin,a))
   {
       int len=a.length();
       for(int i=0;i


行结果有兴趣的可以自己运行看看。(其实是 我附不上图片)




你可能感兴趣的:("尚学堂杯"哈尔滨理工大学第七届程序设计竞赛 F.Final Ugly English(字符串处理))