*1022. D进制的A+B【考前最后一道题】
/*
*Main.c
*1022. D进制的A+B Ver.1
*Created on : 2014.9.5
*****测试通过******
*/ #include <stdio.h>
#include <stdlib.h> void cal1(int sum, int D); int main(void){ int A, B, sum;//题目中的A、B
int D; scanf_s("%d %d %d", &A, &B, &D); sum = A + B; cal1(sum, D);
printf("\n"); system("pause");
return ; } void cal1(int sum, int D){ if (sum / D != ){
cal1(sum / D, D);
}
printf("%d", sum%D);
}
/*
*Main.c
*1022. D进制的A+B Ver.2
*Author : Boomkeeper
*Created on : 2014.9.5
*****部分通过****
*/ #include <stdio.h>
#include <stdlib.h> void cal2(int sum, int D); int main(void){ int A, B, sum;//题目中的A、B
int D; scanf("%d %d %d", &A, &B, &D); sum = A + B; cal2(sum, D);
printf("\n"); system("pause");
return ; } void cal2(int sum, int D){ int array[];
int i = ; while (sum != ){
array[i++] = sum%D;
sum /= D;
} if (array[i - ] == )
i = i - ;
else
i = i - ;
while (i >= ){
printf("%d", array[i]);
i--;
}
}

明天奔赴考场,今晚最后一题练手,希望顺利!
同祝“PATers”凯旋!
(话说从Eclipse转到VS上真是憋手蹩脚%>_<%)
题目链接:
http://pat.zju.edu.cn/contests/pat-b-practise/1022
参考:
http://blog.csdn.net/janestar/article/details/28632193
*1022. D进制的A+B【考前最后一道题】的更多相关文章
- 1022. D进制的A+B (20)
1022. D进制的A+B (20) 时间限制 100 ms 内存限制 32000 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 输入两个非负10进制整数A和 ...
- PAT乙级 1022. D进制的A+B (20)
1022. D进制的A+B (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 输入两个非负10进制整数A和 ...
- PAT-乙级-1022. D进制的A+B (20)
1022. D进制的A+B (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 输入两个非负10进制整数A和 ...
- PAT (Basic Level) Practice (中文)1022 D进制的A+B
1022 D进制的A+B 输入两个非负 10 进制整数 A 和 B (≤2^30^−1),输出 A+B 的 D (1<D≤10)进制数. 输入格式: 输入在一行中依次给出 3 个整数 A.B 和 ...
- 1022 D进制的A+B (20)(20 分)
1022 D进制的A+B (20)(20 分) 输入两个非负10进制整数A和B(<=\(2^{30}-1\)),输出A+B的D (1 < D <= 10)进制数. 输入格式: 输入在 ...
- PAT (Basic Level) Practise (中文)- 1022. D进制的A+B (20)
PAT (Basic Level) Practise (中文)- 1022. D进制的A+B (20) http://www.patest.cn/contests/pat-b-practise/1 ...
- PAT 乙级 1022.D进制的A+B C++/Java
1022 D进制的A+B (20 分) 题目来源 输入两个非负 10 进制整数 A 和 B (≤),输出 A+B 的 D (1)进制数. 输入格式: 输入在一行中依次给出 3 个整数 A.B 和 D. ...
- P 1022 D进制的A+B
转跳点 :
- 1022 D进制的A+B (20 分)
题目:1022 D进制的A+B (20 分) 思路: 首先根据A.B的取值范围,可知A+B不过2^31,所以转换成进制数时的最长长度为31. 转换成进制的数存进数组,然后反向输出. 要注意和为0的情况 ...
随机推荐
- PROCEDURE_监测系统_告警信息存储过程—产生告警信息插入告警表
create or replace procedure proc_alarmlog(in_id in number, --采集器编码 ...
- mac终端 使用摘要
Root (拥有对此计算机的所有权限) 查看当前用户:who 切换到root(默认系统是不会使用root的):sudo -s 然后输入密码 更改密码:passwd
- js 创建对象
1.工厂模式 function createPerson(name, age, job) { var o = new Object(); o.name = name; o.age = age; o.j ...
- Linux APP源码级编译安装
首先需要了解下tar包. 以下文章作出解释了: http://www.cnblogs.com/laipDIDI/articles/2214270.html http://baike.baidu.com ...
- Implement Queue using Stacks 解答
Question Implement the following operations of a queue using stacks. push(x) -- Push element x to th ...
- Merge Two Sorted Lists 解答
Question Merge two sorted linked lists and return it as a new list. The new list should be made by s ...
- cc150 Chapter 2 | Linked Lists 2.5 add two integer LinkedList, return LinkedList as a sum
2.5 You have two numbers represented by a linked list, where each node contains a single digit. The ...
- oracle获取某一字段字符串长度
用length方法 select t.* from tp_area t where substr(t.area_id,0,2)='03' and length(t.area_id)>2
- java Socket 使用注意
Socket s = new Socket(ia, port); BufferedOutputStream bufOut = new BufferedOutputStream(s.getOutputS ...
- JDBC官方用法
JDBC官方用法https://bitbucket.org/xerial/sqlite-jdbc/#markdown-header-usage 代码下载https://github.com/xeria ...