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) ...
随机推荐
- 2016NOIP总结
从暑假开始学OI到现在,也已经过了4个月.说实话真是快啊...感觉没学什么东西就要去比赛了.怎么说呢,感觉自己真的是个菜鸡啊为什么就要去比赛呢.当初来到这里,是凭着兴趣来的,第一天能打那么多道题(19 ...
- 验证mongodb主从复制过程~记录操作
接 mongodb的安装:http://www.cnblogs.com/myrunning/p/4319367.html 1.1创建数据目录 在这里我们将不使用mongodb的配置文件启动mongod ...
- Delphi自己隐藏自定义弹出列表
先上代码 procedure TForm3.Timer1Timer(Sender: TObject); var Point: TPoint; Name: array[0..255] of Char; ...
- node如何让一个端口同时支持https与http
众所周知node是一个高性能的web服务器,使用它可以很简单的创建一个http或https的服务器. 比如一个很简单的http服务器: var http = require('http'); var ...
- Python读取二进制文件
import os import sys import socket mypath = sys.argv[1] if not os.path.exists(mypath): print "T ...
- 深圳本土web前端经验交流
群号:125776555 深圳本土web前端技术交流群 baidu tencent前端拒绝垃圾广告.吹水,欢迎讨论技术.跳槽经验期待您的加入
- 久违的问候-----eclipse中搭建maven项目2016年
好久没有写过博客了,可是一直向别人推荐自己的博客,深感惭愧!今天再次在寒冷之夜继续code,config,write. 接下来,我们就来谈下eclipse中搭建maven web工程的步骤!虽然就是一 ...
- ASP.NET MVC 从零开始 - 自动化部署(其二)
这篇文章是从我的 github 博客 http://lxconan.github.io 导入的. 这是这个系列的第五篇了,前四篇请参见: ASP.NET MVC 从零开始 – Create and R ...
- eclipse下打包实践
前提: 配置好打包相关的插件,看打包的结果分别添加不同的plugin,装好m2eclipse. 以下步骤以war包的packing为例. 步骤: 如下图:右键,选择Run As 或者 Debug As ...
- yar框架使用笔记
Yar是什么 Yar是并行的RPC框架(Concurrent RPC framework),Laruence开发. 安装 下载地址:http://pecl.php.net/package/yar wi ...