http://poj.org/problem?id=1503

对于这个题我也是醉了,因为最开始是有学长和我们说过这个题目的,我以为我记得题目是什么意思,也就没看题目,结果按案例去理解题意,结果WA了一晚上,我也是醉醉哒。

最后今天才在discuss发现是我的理解题意错了,改下,就对了。给我一个很大的教训。。。。。

题意很简单,,就是一组大整数的加法而已,终止的标志就是只有一个0输入。

 #include <stdio.h>
#include <string.h> char str[]={};
int a[]={},sum[]={}; int main()
{
while(scanf("%s",str)&&strcmp(str,"")){
int len=strlen(str);
for(int i=,j=len-;i<len;i++,j--) //我用一个a数组的目的就是反正前导0的出现。因为我的数据是从开始到末尾是倒过来的,所以前导0在之后的加法中也是在后面了,不起任何作用。
a[i]=str[j]-'';
for(int i=;i<=;i++){
sum[i]+=a[i];
if(sum[i]>=) {
sum[i+]++;
sum[i]-=;
}
}
memset(str,,sizeof(str)); //初始化,反正之后的str数组较小,只替代了部分之前的str数组。
}
for(int i=,j=;i>;i--){
if(sum[i]==) {
j--;
}
if(i!=j)printf("%d",sum[i]);
}
printf("%d\n",sum[]);
return ;
}

POJ 1503的更多相关文章

  1. POJ 1503 Integer Inquiry 大数 难度:0

    题目链接:http://poj.org/problem?id=1503 import java.io.*; import java.math.BigInteger; import java.util. ...

  2. Poj 1503 Integer Inquiry

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

  3. poj 1503 Integer Inquiry (高精度运算)

    题目链接:http://poj.org/problem?id=1503 思路分析: 基本的高精度问题,使用字符数组存储然后处理即可. 代码如下: #include <iostream> # ...

  4. POJ 1503 Integer Inquiry(大数相加)

    一.Description One of the first users of BIT's new supercomputer was Chip Diller. He extended his exp ...

  5. POJ 1503 Integer Inquiry(大数相加,java)

    题目 我要开始练习一些java的简单编程了^v^ import java.io.*; import java.util.*; import java.math.*; public class Main ...

  6. POJ 1503 Integer Inquiry 简单大数相加

    Description One of the first users of BIT's new supercomputer was Chip Diller. He extended his explo ...

  7. poj 1503 大数相加(java)

    代码: import java.math.*; import java.util.Scanner; public class Main { public static void main(String ...

  8. POJ 1503 大整数

    之前做的大整数,都是一位一位操作. 优化方案:压缩方案. 模板: + - *  操作符重载 #include<cstdio> #include<iostream> #inclu ...

  9. poj 1503 高精度加法

    把输入的数加起来,输入0表示结束. 先看我Java代码,用BigINteger类很多东西都不需要考虑,比如前导0什么的,很方便.不过java效率低点,平均用时600ms,C/C++可以0ms过. im ...

随机推荐

  1. Xcode pch文件问题

    创建后需修改 Prefix Header Debug.Release 为:项目名称/PrefixHeader.pch/ #import <UIKit/UIKit.h>#import < ...

  2. jQuery1.9.1源码分析--数据缓存Data模块

    jQuery1.9.1源码分析--数据缓存Data模块 阅读目录 jQuery API中Data的基本使用方法介绍 jQuery.acceptData(elem)源码分析 jQuery.data(el ...

  3. 在ashx中使用Server对象

    Server.MapPath() System.Web.HttpContext.Current.Server.MapPath()

  4. Perl 正则表达式

    匹配:m/<regexp>;/ (还可以简写为 /<regexp>;/ ,略去 m)替换:s/<pattern>;/<replacement>;/转化: ...

  5. PHP魔术方法以及关于独立实例与相连实例的讲解

    <?php //魔术方法 //当包含多个类 //1.自动装载类的魔术方法__autoload() function __autoload($classname){ if (isset($clas ...

  6. vs 工程连接错误

    现象: estMemPool.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: _ ...

  7. Javascript高级程序设计——this、闭包、函数表达式

    在javascript中函数声明会被提升,而函数表达式不会被提升.当函数执行时,会创建一个执行环境和相应的作用域链,然后利用arguments和其他的命名参数的值来初始化函数的活动对象,作用域链链中所 ...

  8. Triangle leetcode

    Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent n ...

  9. SQL Server中TEXT类型字段值在数据库中追加字符串方法

    在数据上我们往往会遇到ntext大文本类型,这种类型如果和 nvarchar类型相加会出现问题,所以有一中方法可以解决这种问题. 使用的sql   函数: TEXTPTR:返回要更新的 text.nt ...

  10. Ehcache与Guava Cache的区别浅谈

    最近在做一些缓存改造的场景,有如下一些经验总结: 缓存版本: Ehcache:2.8.3 Guava:17.0 Ehcache支持持久化到本地磁盘,Guava不可以: Ehcache有现成的集群解决方 ...