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

#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. Hibernate4Maven

    How to create a Maven project with Hibernate libs? This blog will be a demo to describe this issue. ...

  2. winform中键盘和鼠标事件的捕捉和重写(转)

    在 编写winform应用程序时,有时需要无论在哪个控件获取焦点时,对某一个键盘输入或者鼠标事件都进行同样的操作.比如编写一个处理图片的应用程序时, 希望无论当前哪个控件获得焦点,当用户按上.下.左. ...

  3. Linux下mongodb的安装及启动

    安装 1>设置mongoDB目录 cd /home/apps 附:centOS下创建目录命令  mkdir /home/apps 2>下载mongodb curl -O http://fa ...

  4. js判断微信浏览器

    function is_weixin(){ //检查是否是微信浏览器 var ua = navigator.userAgent.toLowerCase(); if(ua.match(/MicroMes ...

  5. android-Intent and IntentFilter

    一.Intent简介 Android使用Intent来封装程序的调用"意图",Activity.Service.BroadcastReceiver三种重要的组件都是依靠Intent ...

  6. Oracle10g RAC的简单操作

    1.查看OCR位置用户指定的位置会被放置在 /etc/oracle/ocr.loc(Liunx系统) 或 /var/opt/oracle/ocr.loc [oracle@rac4 opt]$ cat ...

  7. 对struct和class使用大括号初始化的测试

    #include <iostream> using namespace std; struct struct1{ /* struct1(){ cout<<"this ...

  8. window常见事件

    <script type="text/javascript"> /*onunload = function(){ alert("onunload run&qu ...

  9. java.lang.UnsupportedClassVersionError: Bad version number in .class file异常

    java.lang.UnsupportedClassVersionError: Bad version number in .class file异常 部署工程时也出现过因为版本不同引起的问题,那时我 ...

  10. 奥迪--Q5

    -型号:Q5 -价格:40-53W -动力:2T -变速箱:8挡手自一体 -长宽高:4.63,1.90,1.66 -油箱:75L -发动机:EA888 -大灯:氙气