ZOJ 1295——Reverse Text
来源:互联网 发布:清华 软件硕士 编辑:程序博客网 时间:2024/05/22 23:59
在没学STL之前,可能做这道题需要开数组,在出现空格的地方外加判断,但是学完string,一条reverse语句便将输入逆转,c语音可能需要2-30行,可见c++的优化。注意:输入有空格,要用getline (cin,a);
code:
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int main (){
string a;
int n;
cin>>n;
getchar(); //吸收换行
for (int i=0;i<n;i++)
{
getline (cin,a);
reverse(a.begin(),a.end());
cout<<a<<endl;
}
}
0 0
- ZOJ 1295——Reverse Text
- zoj 1295 Reverse Text
- zoj 1295 Reverse Text
- ZOJ 1295 Reverse Text
- ZOJ 1295 Reverse Text
- ZOJ 1295: Reverse Text
- ZOJ - 1295 - Reverse Text
- ZOJ 1295 - Reverse Text
- ZOJ - 1295 Reverse Text
- ZOJ Problem Set - 1295 Reverse Text
- ZOJ 1295: Reverse Text - cin.getline()
- ZOJ Problem Set - 1295 Reverse Text
- ZOJ Problem Set - 1295 Reverse Text
- zoj 1295.Reverse Text
- hdu1062——Text Reverse
- HDU 1062 — Text Reverse
- hdu——1062Text Reverse(反转函数reverse)
- 1295 Reverse Text
- 背包九讲
- C++中几种将整数转换成二进制输出的方法
- 快速pow和sqrt的小技巧 hdu4282
- pow(x,y)函数
- ZOJ 2060----Fibonacci Again
- ZOJ 1295——Reverse Text
- ZOj 2104——Let the Balloon Rise
- Zoj 2947——Abbreviation
- ZOJ 1151——Word Reversal
- 总结:创建maven项目时可能会出现的问题
- 【转载】输出二进制 C
- #define和const的区别
- 【转载】define与typedef区别与联系
- C语言整理-7