#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. Net Core Docker

    Net Core Docker轻量级的web框架   .net core现在已经有了大的发展,虽然笔者现在已经从事python开发,但是一直在关注.net的发展,在逛博客园的时候,发现有大家都会提到N ...

  2. 百度预测 及 maven pom搜索地址

    http://trends.baidu.com/ http://mvnrepository.com/artifact/net.sourceforge.htmlcleaner/htmlcleaner/2 ...

  3. hdu 4749

    题目很简单,不过题意很难看懂. 就是给一个标准的大小关系的队列,从原队列中找出最多的匹配子队列,感觉就像一个KMP算法+贪心: 不过这个题可能数据有点水把,竟然只要判断相邻的关系就可以A掉: 代码: ...

  4. Gartner 如何看 RASP 和 WAF?

    在这个计算机网络飞速发展的网络时代里,新兴的网络威胁正在不断「侵蚀」着的应用程序和核心数据的安全,各种繁杂的防护手段也随之接踵而来.众所周知,Gartner 是全球最具权威的 IT 研究与顾问咨询公司 ...

  5. 搭建mongodb分片

    搭建mongodb分片 http://gong1208.iteye.com/blog/1622078 Sharding分片概念 这是一种将海量的数据水平扩展的数据库集群系统,数据分表存储在shardi ...

  6. 23个移动app界面上的旋钮和刻度盘设计示例

      摘要: 从最初进入电子设备领域,旋钮和刻度盘的由最初的功能性设计转变为时尚的外观设计元素,比如在移动app中.这种转变并意外,旋钮和刻度盘不需要占用移动设备的太多空间,并可以简单地为用户提供一些列 ...

  7. ☀【canvas】直线 / 三角形 / 矩形 / 曲线 / 控制点 / 变换

    <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8& ...

  8. sql server 清除日志

    SQL2008 的收缩日志  由于SQL2008对文件和日志管理进行了优化,所以以下语句在SQL2005中可以运行但在SQL2008中已经被取消: (SQL2005) Backup Log DNNam ...

  9. python 零散记录(二) 序列的相关操作 相加 相乘 改变 复制

    序列相加: [1,2] + [3,4] == [1,2,3,4] #字符串也是序列的一种 'hello' + 'world' == 'hello world' #但是序列相加只限于相同类型的序列间相加 ...

  10. Ruby跳出多层循环 catch...throw

    在编码的时候,有时候会遇到嵌套循环的情况,最内部的循环结束的时候,想跳出所有循环,这个时候我们往往采用通过内部循环设置一个flag来控制外部跳出循环条件,比如: #encoding:utf-8 for ...