zju 1295 Reverse Text

Reverse Text


Time Limit: 2 Seconds      Memory Limit: 65536 KB


In most languages, text is written from left to right. However, there are other languages where text is read and written from right to left. As a first step towards a program that automatically translates from a left-to-right language into a right-to-left language and back, you are to write a program that changes the direction of a given text.


Input Specification

The input contains several test cases. The first line contains an integer specifying the number of test cases. Each test case consists of a single line of text which contains at most 70 characters. However, the newline character at the end of each line is not considered to be part of the line.

Output Specification

For each test case, print a line containing the characters of the input line in reverse order.

Sample Input

3
Frankly, I don‘t think we‘ll make much
money out of this scheme.
madam I‘m adam

Sample Output

hcum ekam ll‘ew kniht t‘nod I ,ylknarF
.emehcs siht fo tuo yenom
mada m‘I madam

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    n=0;
    string s;
    char ss[80];
    while(cin.getline(ss,80))
    {
        if(n==0) n=1;
        else
            {
             s=ss;
            reverse(s.begin(),s.end());
        cout<<s<<endl;
        }

    }
    return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    n=0;
    string s;
    char ss[80];
    while(cin.getline(ss,80))
    {
     if(n==0) n=1;
     else
   {
       s=ss;
      reverse(s.begin(),s.end());
        cout<<s<<endl;
     }
     
       
    }
    return 0;
}

zju 1295 Reverse Text

时间: 2024-10-29 00:06:51

zju 1295 Reverse Text的相关文章

HDU1321 ZOJ1295 Reverse Text

问题链接:HDU1321 ZOJ1295 Reverse Text.基础训练级的题,用C语言编写. 这个问题是首先输入测试例子数量t,然后输入t行字符串,将每一行逆序输出. 利用堆栈后进先出的原理,逆序处理可以使用堆栈来实现. 程序中,使用了一个自行实现的堆栈,简单地实现逆序功能. 本程序使用getchar()函数处理输入流,除了输入字符压栈外,读入的字符直接输出输出,没有使用多余的缓存. 这个问题类似于HDU1062 Text Reverse. AC通过的C语言程序如下: /* HDU1321

TJU Problem 1644 Reverse Text

注意: int N; cin >> N; cin.ignore(); 同于 int N; scanf("%d\n",&N); 另:关于 cin 与 scanf: scanf是格式化输入,printf是格式化输出. cin是输入流,cout是输出流.效率稍低,但书写简便. 格式化输出效率比较高,但是写代码麻烦. 流输出操作效率稍低,但书写简便. cout之所以效率低,正如一楼所说,是先把要输出的东西存入缓冲区,再输出,导致效率降低. 缓冲区比较抽象,举个例子吧: 曾经

HDOJ/HDU 1321 Reverse Text(倒序输出~)

Problem Description In most languages, text is written from left to right. However, there are other languages where text is read and written from right to left. As a first step towards a program that automatically translates from a left-to-right lang

杭电ACM1321——Reverse Text~~逆序输出字符串

简单的字符串逆序输出. AC代码: #include <iostream> #include <cstring> using namespace std; int main() { char str[100000]; int n; while(cin >> n) { getchar(); for(int i = 0; i < n; i++) { gets(str); int length = strlen(str); for(int j = length - 1;

POJ百道水题列表

以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight Moves1101 Gamblers1204 Additive equations 1221 Risk1230 Legendary Pokemon1249 Pushing Boxes 1364 Machine Schedule1368 BOAT1406 Jungle Roads1411 Annive

zoj题目分类

饮水思源---zoj 转载自:http://bbs.sjtu.edu.cn/bbscon,board,ACMICPC,file,M.1084159773.A.html 注:所有不是太难的题都被归成了“简单题”,等到发现的时候已经太晚了,我太死脑筋 了……:( 有些题的程序我找不到了,555……:( SRbGa的题虽然都很经典……但是由于其中的大部分都是我看了oibh上的解题报告后做 的,所以就不写了…… 题目排列顺序没有规律……:( 按照个人感觉,最短路有的算做了DP,有的算做了图论. 有些比较

杭电ACM分类

杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDIATE DECODABILITY

【转】对于杭电OJ题目的分类

[好像博客园不能直接转载,所以我复制过来了..] 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDI

转载:hdu 题目分类 (侵删)

转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029. 1032.1037.1040.1048.1056.1058.1061.1070.1076.1089.1090.1091.1092.1093. 1094.1095.1096.1097.1098.1106.1108.1157.116