"尚学堂杯"哈尔滨理工大学第七届程序设计竞赛——Hrbust2330 Final Ugly English
2017-04-02 22:35
417 查看
Final Ugly English
Time Limit: 1000 MS Memory Limit: 32768 K
Total Submit: 52(15 users) Total Accepted: 19(15 users) Rating: 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
大概意思就是直接调转每个单词
Time Limit: 1000 MS Memory Limit: 32768 K
Total Submit: 52(15 users) Total Accepted: 19(15 users) Rating: 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
大概意思就是直接调转每个单词
#include<stdio.h> #include<string.h> int main() { char a[1008],b[1008]; int i; while(gets(a)) { int n=strlen(a); int flag=0; for(i=0; i<n; i++) { if(a[i]!=' ') { b[flag++]=a[i]; } else///再次遇到空格的时候,因为flag被初始化为0了,且遇到单词字母前不会再增加 { for(int j=flag-1; j>=0; j--) { printf("%c",b[j]); } flag=0; printf("%c",a[i]);///把空格输出来 } } for(i=flag-1; i>=0; i--)///最后一个单词 { printf("%c",b[i]); } printf("\n"); } return 0; }
相关文章推荐
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛 F Final Ugly English
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛 F.Final Ugly English(字符串处理 4000 )
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛 F.Final Ugly English(字符串处理)
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛——Hrbust2327 Collection Game
- HRBUST 2331 Great Atm 尚学堂杯"哈尔滨理工大学第七届程序设计竞赛
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛——Hrbust2326 Blind Father
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛 hrbust 2331 Great Atm
- HRBUST 2326 Blind Father "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛
- HRBUST 2327 Collection Game "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛 D.Distinct Package Manager【Dfs+模拟】
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛 G.Great Atm(二进制,位运算)
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛 G.Great Atm【贪心】
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛 G(2331) Great Atm(二进制)(思路)
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛 G(2331) Great Atm(二进制)(思路)
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛 G(2331) Great Atm(二进制)(思路)
- 20170402"尚学堂杯"哈尔滨理工大学第七届程序设计竞赛ABCDFG题解
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛 G(2331) Great Atm(二进制)(思路)
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛 G(2331) Great Atm(二进制)(思路)
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛 G(2331) Great Atm(二进制)(思路)
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛D--Distinct Package Manager