ZOJ Problem Set - 1292 Integer Inquiry
题目本身属于简单题,但是注意在输出的时候,题目很变态的对格式做了很多要求:
1.输入的N与下面的block有一个空行
2.每次输出与下一个输入的block有一个空行
3.但是特别注意,当是最后一个输出时不需要输出空行
见代码:
#include <stdio.h>
#include <string.h> void invert(char *a)
{
int l=strlen(a);
for(int i=,j=l-;i<j;i++,j--)
{
char t;
t=a[i];
a[i]=a[j];
a[j]=t;
}
} char * sum(char *a,char *b) //length of a is biger than b
{
int la=strlen(a),lb=strlen(b);
int c=,i; for(i=;i<lb;i++)
{
int t=a[i]+b[i]-''-''+c;
if(t/!=)
{
c=t/;
t=t%;
a[i]=t+'';
}
else
{
a[i]=t+'';
c=;
}
} if(c!=)
{
for(i=lb;i<la;i++)
{
int t=a[i]+c-'';
if(t/!=)
{
c=t/;
t=t%;
a[i]=t+'';
}
else
{
a[i]=t+'';
c=;
break;
}
}
if(c!=)
{
a[i++]=c+'';
a[i]='\0';
}
} return a;
} int main()
{
int N;
scanf("%d",&N); while(N--)
{
getchar();
char t[],result[];
int i=;
scanf("%s",t);
if(!strcmp(t,""))
{
printf("0\n");
continue;
}
else
{
invert(t);
strcpy(result,t);
} while(scanf("%s",t)!=EOF&&strcmp(t,""))
{
int lr=strlen(result),lt=strlen(t);
invert(t);
if(lr>=lt)
strcpy(result,sum(result,t));
else
strcpy(result,sum(t,result));
}
invert(result);
printf("%s\n",result);
if(N>) printf("\n");
} return ;
}
ZOJ Problem Set - 1292 Integer Inquiry的更多相关文章
- Problem D: Integer Inquiry
Problem D: Integer InquiryTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 41 Solved: 12[Submit][Status ...
- hdu acm-1047 Integer Inquiry(大数相加)
Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- Integer Inquiry【大数的加法举例】
Integer Inquiry Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 27730 Accepted: 10764 ...
- hdu1047 Integer Inquiry
/* Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- hdu 1047 Integer Inquiry
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1047 Integer Inquiry Description One of the first use ...
- Poj 1503 Integer Inquiry
1.链接地址: http://poj.org/problem?id=1503 2.题目: Integer Inquiry Time Limit: 1000MS Memory Limit: 1000 ...
- hdoj 1047 Integer Inquiry
Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- ZOJ Problem Set - 3593 拓展欧几里得 数学
ZOJ Problem Set - 3593 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3593 One Person ...
- (大数 string) Integer Inquiry hdu1047
Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
随机推荐
- 吐槽scala
scala可能是唯一一个编译器和IDE对代码有不同理解的语言.当你开始用scala的高级特性的时候,他们的分歧特别的大,以至于现在,intellij上的scala插件已经不敢对可能编译不通过的代码标记 ...
- java 过滤器Filter
一.首先在web.xml里进行拦截过滤 <filter> <filter-name>platformServiceAgreementFilter</filt ...
- 在页面使用js回车键
网上有大量的文章关于 js回车事件的,但是只有适合自己的才是最好的. 第一种: // submit closest form $(".keydown_submit").keydow ...
- ZXing二维码生成在Unity3D中出错,数组超出界限的解决办法
错误截图: IndexOutOfRangeException: Array index is out of range.ZXing.Color32Renderer.Render (ZXing.Comm ...
- ASP.NET TextBox 当鼠标点击后清空默认提示文字
ASP.NET TextBox 当鼠标点击后清空默认提示文字 [ 方法一] 前台代码: <div> <asp:TextBox ID="txtName" ru ...
- 有Maple T.A.自有试题图so easy
对于想完全控制试题库的用户而言,Maple T.A.是最好的选择.不论您是要利用现有的题库,还是要创建自己的题库,Maple T.A.都可以为您提供功能强大.操作便捷的工具创建数学内容. 1) Ste ...
- PHP的日期和时间处理函数
1. 将日期和时间转变为时间戳 1.1 time() 原型:time(void) 作用:返回当前时间的 UNIX时间戳. 参数:void,可选(即无参数) 1.2 mktime() 原型:int mk ...
- ESENT分布式数据存储
关于ESENT,我能想到最恰当的比喻是,它是Microsoft世界的BerkeleyDB,鲜为人知,很少有.NET开发人员使用它,rhino-queues项目使用就是它,但它的性能和可靠性已经经受住了 ...
- 当我谈 "加班有罪" 我在谈什么?
前言 PS. 本文只描述IT行业. 博客园果真人气比较高,我之前准备写个 "领域驱动系列",然后感觉大家不感兴趣,看来用的人不多,所以一直没动力续,但是昨天写了 [加班有罪] (h ...
- Microsoft Azure Web Sites应用与实践【1】—— 打造你的第一个Microsoft Azure Website
Microsoft Azure Web Sites应用与实践 系列: [1]—— 打造你的第一个Microsoft Azure Website [2]—— 通过本地IIS 远程管理Microsoft ...