题目本身属于简单题,但是注意在输出的时候,题目很变态的对格式做了很多要求:

1.输入的N与下面的block有一个空行

2.每次输出与下一个输入的block有一个空行

3.但是特别注意,当是最后一个输出时不需要输出空行

见代码:

#include <stdio.h>
#include <string.h>void invert(char *a)
{int l=strlen(a);for(int i=0,j=l-1;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=0,i;for(i=0;i<lb;i++){int t=a[i]+b[i]-'0'-'0'+c;if(t/10!=0){c=t/10;t=t%10;a[i]=t+'0';}else{a[i]=t+'0';c=0;}}if(c!=0){for(i=lb;i<la;i++){int t=a[i]+c-'0';if(t/10!=0){c=t/10;t=t%10;a[i]=t+'0';}else{a[i]=t+'0';c=0;break;}}if(c!=0){a[i++]=c+'0';a[i]='\0';}}return a;
}int main()
{int N;scanf("%d",&N);while(N--){    getchar();char t[110],result[110];int i=0;scanf("%s",t);if(!strcmp(t,"0")) {printf("0\n");continue;}else {invert(t);strcpy(result,t);}while(scanf("%s",t)!=EOF&&strcmp(t,"0")){int lr=strlen(result),lt=strlen(t);invert(t);if(lr>=lt)strcpy(result,sum(result,t));elsestrcpy(result,sum(t,result));}invert(result);printf("%s\n",result);if(N>0) printf("\n");}return 0;
}

转载于:https://www.cnblogs.com/xlturing/p/3340299.html

ZOJ Problem Set - 1292 Integer Inquiry相关推荐

  1. ZOJ 1292 Integer Inquiry

    https://zoj.pintia.cn/problem-sets/91827364500/problems/91827364791 题意:先输入一个数  表示测试样例的个数,接着输入几个数(可以不 ...

  2. hdu 1047 Integer Inquiry

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1047 Integer Inquiry Description One of the first use ...

  3. HDOJ 1047 Integer Inquiry

    JAVA睑板.... Integer Inquiry Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Ja ...

  4. Poj 1503 Integer Inquiry

    1.链接地址: http://poj.org/problem?id=1503 2.题目: Integer Inquiry Time Limit: 1000MS   Memory Limit: 1000 ...

  5. Argus(ZOJ Problem Set - 2212)(优先队列)

    Argus   时间限制(普通/Java):1000MS/3000MS     运行内存限制:65536KByte 总提交: 3            测试通过: 2 描述 A data stream ...

  6. ZOJ Problem 1005 jugs

    题目 In the movie "Die Hard 3", Bruce Willis and Samuel L. Jackson were confronted with the ...

  7. ZOJ Problem Set - 1331 Perfect Cubes

    这个题啊,一看就是暴力,暴力,暴力!!! 但是,暴力也是要做到暴力的恰到好处:看题 For hundreds of years Fermat's Last Theorem, which stated ...

  8. HDU 1047 Integer Inquiry( 高精度加法水 )

    链接:传送门 思路:高精度水题 /*************************************************************************> File ...

  9. ZOJ Problem Set - 1048 Financial Management

    我承认这是一道水的不能再水的题,今天一下就做到了,还是无耻的帖上来吧 #include <stdio.h>int main() {double sum=0;for(int i=1;i< ...

  10. ZOJ Problem Set - 3329 One Person Game

    题目大意:有三个骰子,分别有k1,k2,k3个面. 每次掷骰子,如果三个面分别为a,b,c则分数置0,否则加上三个骰子的分数之和. 当分数大于n时结束.求游戏的期望步数.初始分数为0分析 设 E[i] ...

最新文章

  1. ImageNet时代将终结?何恺明新作:Rethinking ImageNet Pre-training
  2. 【软件期刊01】2017-02-22
  3. 你所不知道的日志异步落库
  4. (4.7)mysql备份还原——深入解析二进制日志(3)binlog的三种日志记录模式详解...
  5. dns服务器zones文件,DNS服务安装与配置
  6. centos7 搭建Docker Registry
  7. 考研英语核心词汇辨析(黑魔方系列2007版之十二)
  8. 268 missing number
  9. 俺是如何在3个月内写出博士论文的?
  10. UFLDL教程笔记及练习答案三(Softmax回归与自我学习***)
  11. Hibernate 一对一关联查询
  12. TSQL--查找连续登陆用户
  13. [删括号][判断可行性的dp]
  14. 讨厌的任意门事件,删了会出系统提示:安装prosheild.msi问题,不要乱删!
  15. 【数电基础知识】各逻辑运算符号盘点
  16. SGD: Maximum margin separating hyperplane程序解析
  17. ubuntu14.04安装Y430P-GTX850M的nvidia驱动和cuda-8.0
  18. 浏览器开代理后,https地址打不开
  19. 开源项目-CRM客户关系管理系统
  20. pii 400_为什么要加密所有个人身份信息(PII)

热门文章

  1. 南昌项目中镜像系统时遇到的问题
  2. LINUX使用C调用LMDB的方法
  3. mysql一对多前端实现_django一对多模型以及如何在前端实现详解
  4. 软件测试c语言笔试题目,软件测试笔试题库及答案.docx
  5. c++ 深度拷贝和浅度拷贝
  6. c++ 基本知识汇总
  7. linux安装gcc-4.9,centos7.2编译安装gcc-4.9.2
  8. 介绍数据库中的wal技术_简介事务ACID的实现机制
  9. 经验分享 PDF如何旋转页面,替换页面
  10. CentOS7连接无线网络