Reverse Number
http://acm.hdu.edu.cn/showproblem.php?pid=1266
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 65536/32768 K (Java/Others)
Problem Description
Welcome to 2006'4 computer college programming contest!
Specially, I give my best regards to all freshmen! You are the future of HDU ACM! And now, I must tell you that ACM problems are always not so easy, but, except this one... Ha-Ha!
Give you an integer; your task is to output its reverse number. Here, reverse number is defined as follows:
1. The reverse number of a positive integer ending without 0 is general reverse, for example, reverse (12) = 21;
2. The reverse number of a negative integer is negative, for example, reverse (-12) = -21;
3. The reverse number of an integer ending with 0 is described as example, reverse (1200) = 2100.
Input
Input file contains multiple test cases. There is a positive integer n (n<100) in the first line, which means the number of test cases, and then n 32-bit integers follow.
Output
For each test case, you should output its reverse number, one case per line.
Sample Input
Sample Output
水。
完整代码:
/*0ms,208KB*/
#include<cstdio>
#include<cstring>
char s[15];
void solve(char* s)
{
int i, j, len = strlen(s);
for (i = len - 1; i > 0; --i)
if (s[i] != '0') break;
for (j = i; j >= 0; --j) putchar(s[j]);
puts(s + i + 1);
}
int main()
{
int t;
scanf("%d\n", &t);
while (t--)
{
gets(s);
if (s[0] == '-')
{
putchar('-');
solve(s + 1);
}
else solve(s);
}
return 0;
}
分享到:
相关推荐
hdu5102的ac源码。算法:队列、数据结构、图论、模拟。题意:输入一棵树,输出前k小的点对最短距离dis(i,j)的和。
解题报告|ACM|程序设计参考程序以及题目的分析
杭电OJ部分答案,可以很简单的解决a+b求和问题及其他问题。
HDU的一题........HDU DP动态规
杭电OnlineJudge 200-2099的解题报告
杭电选课插件
HDU-1711 Number Sequence(KMP算法)For each test case, you should output one line wh
HDUACM2010版03递推求解.ppt
ACM HDU 1404 Digital Deletions(博弈).docx
HDU 里面的2000~2099道题目的源码。谢谢支持
2.18.1 HDU4656 卷积取模 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 2.19 其它公式 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 2.19.1 Polya . . . ....
杭电 hdu acm 第1084题的解法,ac过了,是一位学长教我的.内有一些中文说明.
ACM HDU题目分类,我自己总结的大概只有十来个吧
Hdu 1020解题报告,http://acm.hdu.edu.cn/showproblem.php?pid=1020
杭电acm 一些java语言实现的水题目
本资源为HDU数字图像处理课程 浙江省在线平台的视频课后作业 仅供参考 假设我们有一个mat型的单通道图像,命名为srcMat,我们想得到第i行,第j列的像素值则可以用一下的代码 A. int value= srcMat.at(i)(j)[0]; B...
杭电ACM2000-2099题的解题报告