HDU 1062 字符串翻转(字符串,水)
来源:互联网 发布:淘宝助理初始化未响应 编辑:程序博客网 时间:2024/05/04 03:18
Problem Description
Ignatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should reverse all the words and then output them.
Input
The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.
Each test case contains a single line with several words. There will be at most 1000 characters in a line.
Output
For each test case, you should output the text which is processed.
Sample Input
3
olleh !dlrow
m’I morf .udh
I ekil .mca
Sample Output
hello world!
I’m from hdu.
I like acm.
好久没写题目了,今天先找了一道水题试试手。
AC:
#include<stdio.h>#include<string.h>#include<iostream>using namespace std;char str[1010];int main(){ char ch; int p,t; cin>>t; getchar(); //输入数字后面scanf字符一定小心 while(t--){ p=0; while(scanf("%c",&ch)){ if(ch==' '){ str[p]='\0'; //字符串结尾的标志 for(int i=p-1;i>=0;i--) cout<<str[i]; cout<<" "; p=0; } else if(ch=='\n'){ for(int i=p-1;i>=0;i--) cout<<str[i]; cout<<endl; break; } else { str[p++]=ch; } } } return 0;}
阅读全文
0 0
- HDU 1062 字符串翻转(字符串,水)
- HDU 1062 字符串翻转 (水题)
- HDU 1062 Text Reverse(字符串翻转)
- HDOJ/HDU 1062 Text Reverse(字符串翻转~)
- 翻转字符串(LintCode)
- 字符串翻转(Java)
- HDU 2037 circumgyrate the string(字符串翻转)
- 翻转字符串
- 翻转字符串
- 字符串翻转
- 字符串翻转
- 翻转字符串
- 翻转字符串
- 字符串翻转
- 翻转字符串
- 翻转字符串
- 字符串翻转
- 翻转字符串
- Linux-4.9.2内核在mini2440上的移植(六)——修改MD9000驱动
- 朴素贝叶斯法
- NB-IOT之一个完整的BC95 UDP从开机到数据发送接收过程
- 谈一谈mmap
- phaser模拟百米赛跑
- HDU 1062 字符串翻转(字符串,水)
- 今天的代码鼓励花
- 国家气象局天气预报SmartWeather API
- Oracle11g下载地址--多平台下的32位和64位
- Java后台框架篇--Struts与SSH
- NOIP2016——纪念第一次水过的一等
- C++学习笔记第一天
- 大学工会组织综合信息管理系统JAVA
- 国内Ubuntu下载地址