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

#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. jquery.autocomplete在火狐下的BUG解决

    该插件在火狐下使用拼音输入法输入,回车后无法即使响应事件,需要再输入别的字母才会响应事件     主要原因:   该插件响应主要监听了keydown事件   其他浏览器在打开中文输入法的情况下输入的拼 ...

  2. man/info

    提示符方面,在linux当中,默认root的提示符为#,而一般身份用户的提示字符为$. 1.重新启动X Window 的快速按钮 一般来说,我们是可以手动来直接修改X Window 的配置文件的,不过 ...

  3. [CareerCup] 17.1 Swap Number In Place 互换位置

    17.1 Write a function to swap a number in place (that is, without temporary variables). 这道题让我们交换两个数, ...

  4. List相关知识点.......课堂加整理

    package lis0924; //接口List(列表) import java.util.ArrayList; import java.util.Iterator; import java.uti ...

  5. jquery ui bootstrap日期插件

    http://blog.csdn.net/php_897721669/article/details/7404527 搜索“jquery ui日期插件怎么显示年份”? $("#datepic ...

  6. 对js中的Date扩展,格式化日期

    /** * 对Date的扩展,将 Date 转化为指定格式的String 月(M).日(d).12小时(h).24小时(H).分(m).秒(s).周(E).季度(q) * 可以用 1-2 个占位符 年 ...

  7. 可以使用mysql自己带的config edit

    正常情况下,一般数据库密码可以写在用户主目录的.my.cnf 然后设置chmod 600,一般来说是比较安全的. 但是如果不想给人知道用户名和实际的密码,但是又想给人用,可以使用mysql自己带的co ...

  8. BizTalk开发系列(十七) 信封架构(Envelop)

    在BizTalk开过中使用信封架构可以提高BizTalk处理性能.比如在使用SQL Adapter时使用信封选取多条记录在通过管道的XML拆装器时将信封里的XML消息部分拆分为单独的消息,发布到Mes ...

  9. IOS第14天(1,UITabBarController的基本的使用)

    **************HMAppDelegate.m - (BOOL)application:(UIApplication *)application didFinishLaunchingWit ...

  10. Visual Studio中删除所有空行

    解决方法如下: 使用快捷键Ctrl+H,显示查找和替换视图菜单 Find what(查找内容):^:b*$\n Replace with(替换为):[Empty] (空字符串,什么都不用填) Look ...