忘了改了什么,后来居然对了!做打不死的菜鸟!

#include <stdio.h>
#include <stdbool.h>
#define arrayLength 20
#define bitMax 1000 main(){
int caseCount = ;
scanf_s("%d", &caseCount); char inputA[arrayLength][bitMax];
char inputB[arrayLength][bitMax];
char result[arrayLength][bitMax + ]; for (int i = ; i < caseCount; i++){ scanf_s("%s", &inputA[i][], );
scanf_s("%s", &inputB[i][], );
}
//Calculating... result[0],result[1]
for (int caseNum = ; caseNum < caseCount; caseNum++)
{
char *ptrA, *ptrB, *ptrResult;
ptrA = inputA[caseNum];
ptrB = inputB[caseNum];
ptrResult = result[caseNum];
int lengthA = getLength(ptrA);
int lengthB = getLength(ptrB);
int lengthMax = lengthA>lengthB ? lengthA : lengthB;
//Fill A or B with zero
if (lengthA > lengthB){
ptrB += lengthB;
for (int j = ; j <= lengthB; j++)
{
char temp = *ptrB;
*(ptrB + lengthA - lengthB) = temp;
ptrB--;
}
ptrB = inputB[caseNum];
for (int i = ; i < lengthA - lengthB; i++){
*ptrB = '';
ptrB++;
}
}
else
{
ptrA += lengthA;
for (int j = ; j <= lengthA; j++)
{
char temp = *ptrA;
*(ptrA + lengthB - lengthA) = temp;
ptrA--;
}
ptrA = inputA[caseNum];
for (int i = ; i < lengthB - lengthA; i++){
*ptrA = '';
ptrA++;
}
}
for (int i = ; i <= lengthMax; i++){
*ptrResult = '';
ptrResult++;
}
*ptrResult = '\0';
bool goAhead = false;
ptrA = &inputA[caseNum][lengthMax - ];
ptrB = &inputB[caseNum][lengthMax - ];
ptrResult--;
//Calculate result[i]
for (int i = ; i < lengthMax; i++)
{ int bitA = *ptrA - '';
int bitB = *ptrB - '';
*ptrResult = '' + (bitA + bitB + goAhead) % ;
if (bitA + bitB + goAhead >= ){
goAhead = true;
}
else
{
goAhead = false;
}
ptrA--;
ptrB--;
ptrResult--;
}
if (goAhead == true){
*ptrResult = '';
}
else
{
ptrResult++;
}
ptrA++;
ptrB++;
for (int bitNum = ; bitNum < lengthMax; bitNum++){
if (*ptrA == '')
ptrA++;
else
{
break;
}
} for (int bitNum = ; bitNum < lengthMax; bitNum++){
if (*ptrB == '')
ptrB++;
else
{
break;
}
}
if (caseNum != caseCount-)
printf("Case %d:\n%s + %s = %s\n\n", caseNum + , ptrA, ptrB, ptrResult);
else
{
printf("Case %d:\n%s + %s = %s\n", caseNum + , ptrA, ptrB, ptrResult);
}
} }
//get string length
int getLength(char *ptr){
int length = ;
while (*ptr != '\0')
{
ptr++;
length++;
}
return length;
}

Problem Description
I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.
Input
The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000.
Output
For each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line is the an equation "A + B = Sum", Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases.
Sample Input
2
1 2
112233445566778899 998877665544332211
Sample Output
Case 1:
1 + 2 = 3 Case 2:
112233445566778899 + 998877665544332211 = 1111111111111111110

ACM Coder [T1002] 一直wrong answer,不知道为什么。上代码!就对就对!的更多相关文章

  1. 有一种感动叫ACM(记WJMZBMR在成都赛区开幕式上的讲话)

    各位选手,各位教练,大家好,我是来自清华大学交叉信息学院的陈立杰,今天很荣幸站在这里代表全体参赛选手发言.对于我来说,这是我第一次正式参加ACM的比赛.不过我跟ACM之间的缘分,大概在很早的时候就已经 ...

  2. ACM题目推荐(刘汝佳书上出现的一些题目)[非原创]

    原地址:http://blog.csdn.net/hncqp/article/details/1758337 推荐一些题目,希望对参与ICPC竞赛的同学有所帮助. POJ上一些题目在http://16 ...

  3. 实验一(不知道怎么上传.docx格式)

    北京电子科技学院(BESTI) 实     验    报     告 课程:深入理解计算机系统        班级:1353 姓名:魏静静 文艺 刘虹辰 学号:20135302 20135331 20 ...

  4. 【ACM】HDU1008 Elevator 新手题前后不同的代码版本

    [前言] 很久没有纯粹的写写小代码,偶然想起要回炉再来,就去HDU随便选了个最基础的题,也不记得曾经AC过:最后吃惊的发现,思路完全不一样了,代码风格啥的也有不小的变化.希望是成长了一点点吧.后面定期 ...

  5. UVALive - 7831 :ACM Tax (主席树求树路径上中位数:LCA+主席树)

    题意:给定一棵带权树,Q次询问,每次询问路径上的中位数. 思路:中位数分边数奇偶考虑,当当边数为num=奇时,结果就算路径第num/2+1大,用主席树做即可... (做了几道比较难的主席树,都wa了. ...

  6. 201521123036 《Java程序设计》第9周学习总结

    本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结异常相关内容. 书面作业 本次PTA作业题集异常 常用异常 题目5-1 1.1 截图你的提交结果(出现学号) 1.2 自己以前编写的代码中 ...

  7. CDOJ_24 八球胜负

    8球是一种台球竞赛的规则.台面上有7个红球.7个黄球以及一个黑球,当然还有一个白球.对于本题,我们使用如下的简化规则:红.黄两名选手轮 流用白球击打各自颜色的球,如果将该颜色的7个球全部打进,则这名选 ...

  8. 【转载】ACM总结

    转自亲学长的总结 声明:本文是写给弱校ACM新手的一点总结,受自身水平和眼界所限,难免会有一些个人主观色彩,希望大牛指正 感谢@Wackysoft .@哇晴天 . @ 一切皆有可能1 的指教,现根据这 ...

  9. 【转】lonekight@xmu·ACM/ICPC 回忆录

    转自:http://hi.baidu.com/ordeder/item/2a342a7fe7cb9e336dc37c89 2009年09月06日 星期日 21:55 初识ACM最早听说ACM/ICPC ...

随机推荐

  1. Java_关于App class loader的总结

    Java本身是一种设计的非常简单,非常精巧的语言,所以Java背后的原理也很简单,归结起来就是两点: 1.JVM的内存管理 理解了这一点,所有和对象相关的问题统统都能解决 2.JVM Class Lo ...

  2. Redis入门笔记(二)-配置及运行

    转自: http://gly199.iteye.com/blog/1056424 1.redis基本参数 redis的配置文件中的常见参数如下: daemonize   是否以后台进程运行,默认为no ...

  3. 重命名PDF打印文件名

    Odoo系统默认打印出来的PDF文件都是以当前文档模型对象对应的模板文件名命名的,对用户来说,这样的命名很不友好. 我们希望能够将打印出来的文件名以单号命名,下面是实现这种目的的方法. 在report ...

  4. log4net 配置应用

    (一). WinForm 或者 WPF 中的配置和应用 <?xml version="1.0" encoding="utf-8" ?> <co ...

  5. Spring的特点

    创始人:Rod Johson1.特点: a:方便解耦和,简化开发,提升性能 b:AOP面向切面的编程 c:声明式事务支持 d:方便程序的调式 e:方便集成各大优秀的框架 f:java源代码学习的典范 ...

  6. js 获取中文的拼音

    es6 + 模块化封装 "use strict"; module.exports = { //参数,中文字符串 //返回值:拼音首字母串数组 makePy (str) { if ( ...

  7. C# 代码笔记

    一.使循环不卡 Application.DoEvents(); System.Threading.Thread.Sleep(5); 二.计算代码运行时间 Stopwatch sw = new Stop ...

  8. 限制EditText只能输入小数点后两位

    设置EditText只能输入小数点后两位,在价格等有限制的输入时特别有效 TextWatcher textWatcher = new TextWatcher() { @Override public ...

  9. 如何使用Jquery自定义命名空间namespace

    // 把生成命名空间的方法绑定在jQuery上 jQuery.namespace = function () { var a = arguments, o = null, i, j, d; for ( ...

  10. iOS 用collectionview 做的无限图片滚动 广告banner适用

    使用方法见demo,bug未知,若有什么问题欢迎留言:) http://files.cnblogs.com/files/n1ckyxu/NickyScrollImageView.zip demo使用s ...