#include<stdio.h>
int main(){
//定义要读入的两个整数
int a,b;
//定义好放拆项用的数组
int D[];
//读入两个整数
scanf("%d%d",&a,&b);
//求和
int ans=a+b;
//如果和是一个负数 ,输出负号,把和变为正数
if(ans<){
printf("-");
ans=-ans;
}
//如果和小于1000 ,直接输出
if(ans<){
printf("%d\n",ans);
}else{
//打算拆分这个和
int zz=;
while(ans>=){
D[zz]=ans%;//得到余数 ,余数是先放入数组的
++zz; //数组下标+1
ans/=; //得到商
}
D[zz]=ans; //把经过运算后的商放入数组的最后一格
printf("%d",D[zz]);//先输出商
//倒着输出
for(int i=zz-;i>=;i--){
printf(",%03d",D[i]);
}
}
return ;
}

最后的运行结果:

PAT---1001. A+B Format (20)的更多相关文章

  1. PAT 1001 A+B Format (20分) to_string()

    题目 Calculate a+b and output the sum in standard format -- that is, the digits must be separated into ...

  2. PAT 1001 A+B Format (20 point(s))

    题目: 我一开始的思路是: 用math.h中的log10函数来计算位数(不建议这么做,因为会很慢,而且会出一点别的问题): 用pow函数根据要插入分号的位置来拆分a+b成一个个数字(例如res / p ...

  3. PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642 题目描述: Calculate a+b and output the sum i ...

  4. PAT 甲级 1001 A+B Format (20)(20 分)

    1001 A+B Format (20)(20 分) Calculate a + b and output the sum in standard format -- that is, the dig ...

  5. PAT 甲级1001 A+B Format (20)(C++ -思路)

    1001 A+B Format (20)(20 分) Calculate a + b and output the sum in standard format -- that is, the dig ...

  6. PAT甲 1001. A+B Format (20) 2016-09-09 22:47 25人阅读 评论(0) 收藏

    1001. A+B Format (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Calculate ...

  7. 【PAT】1001. A+B Format (20)

    1001. A+B Format (20) Calculate a + b and output the sum in standard format -- that is, the digits m ...

  8. 1001.A+B Format (20)代码自查(补足版)

    1001.A+B Format (20)代码自查(补足版) 谢谢畅畅酱的提醒,发现了代码中的不足,把变量名更改成更合理的名字,并且把注释也换成英文啦! 栋哥提供的代码自查的方式也帮助了我发现很多代码中 ...

  9. PAT 1001. A+B Format 解题

    GitHub PDF 1001. A+B Format (20) Calculate a + b and output the sum in standard format -- that is, t ...

  10. 关于‘1001.A+B Format (20)’的解题报告

    1001.A+B Format(20) 首先要感谢一下指导我github上传问题的小伙伴们,捣腾了一整天我终于摸到了一点门路,真的谢谢你们. 小豪的github 问题描述: Calculate a + ...

随机推荐

  1. python,django,mysql版本号查询

    1. ubuntu 下如何查询子集的mysql版本: 方法一: 登录子集的mysql之后就会显示mysql版本: ***:~$ mysql -u root -p Enter password: Wel ...

  2. 合并多个python list以及合并多个 django QuerySet 的方法

    在用python或者django写一些小工具应用的时候,有可能会遇到合并多个list到一个 list 的情况.单纯从技术角度来说,处理起来没什么难度,能想到的办法很多,但我觉得有一个很简单而且效率比较 ...

  3. TEA算法

    我们要讨论的最后一个分组密码加密算法是TEA(Tiny Encryption Algorithm).到目前为止,我们在前面所呈现的连线图可能会使你得出如下结论:分组密码加密算法必须是复杂的.TEA却能 ...

  4. 17.1.2 Replication Formats

    17.1.2 Replication Formats 复制格式 17.1.2.1 Advantages and Disadvantages of Statement-Based and Row-Bas ...

  5. VirtualBox的四种网络连接方式详解

    VirtualBox中有4中网络连接方式: 1. NAT 2. Bridged Adapter 3. Internal 4. Host-only Adapter VMWare中有三种,其实他跟VMWa ...

  6. POJ_2100_Graveyard_Design_(尺取法)

    描述 http://poj.org/problem?id=2100 求连续平方和=n的序列个数,并输出序列. Graveyard Design Time Limit: 10000MS   Memory ...

  7. (转载)js----对象直接量

    (转载)http://blog.csdn.net/greymouseyu/article/details/4015676 对象直接量提供了另一种创建新对象的方式.对象直接量允许将对象描述文字嵌入到Ja ...

  8. [PeterDLax著泛函分析习题参考解答]第7章 Hilbert 空间结果的应用

    1. 对测度是 $\sigma$ 有限的情形证明 Radon-Nikodym 定理. 证明: 设 $\mu,\nu$ 均为 $\sigma$ 有限的非负测度, 则存在分割 $$\bex X=\cup_ ...

  9. jquery+NHibernate3.3.3+MVC的分页效果

    目录结构 先设计数据表结构 DROP SEQUENCE BDLLY_2V.SEQ_CUSTOMER; CREATE SEQUENCE BDLLY_2V.SEQ_CUSTOMER START MAXVA ...

  10. 关于 Unity NavMesh 数据的访问

    目前的工作需要加入自动寻路,后来决定使用 unity 自带的 NavMesh,但有个问题是这个寻路数据,服务器也是需要的,那么我就要把这个数据导出为服务器所用才行.      但 NaveMesh 暂 ...