PAT 1001. A+B Format 解题】的更多相关文章

GitHub PDF 1001. A+B Format (20) Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits). 解题思路 将a+b的值先存在sum中,再逐个分解sum的数字,将组成sum的所有数字存到数组中,由…
题目链接:传送门 题目简述: 1. 给定两个整数值a,b: 2.范围-1000000 <= a, b <= 1000000: 3.按指定格式输出结果 例:-100000 9 输出: -99,991 解题思路: 1.明确范围     a+b在正负两百万范围内, 32位系统int类型占4字节精度够 2.明确要求: ① 输入以空格分割, 输入整数 ②结果如果数字大于4位, 需要每三位用逗号分割 ③视算法可能有需要补零的情况(我就是踩的这个坑) ④正负号提前判定, 便于后面处理 ⑤函数要以return…
题目 Calculate a+b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits). Input Specification: Each input file contains one test case. Each case contains a…
#include<cstdio> #include<cstring> using namespace std; char s[10]; int main() { int a,b; while(scanf("%d%d",&a,&b)==2) { memset(s,0,sizeof(s)); a=a+b; if(a==0) { printf("0\n"); continue; } int aa=a; b=0; if(a<0)…
题目: 我一开始的思路是: 用math.h中的log10函数来计算位数(不建议这么做,因为会很慢,而且会出一点别的问题): 用pow函数根据要插入分号的位置来拆分a+b成一个个数字(例如res / pow(10, len - 3)来获得千位以前的数字),从左往右依次输出,同时在对应位置输出,: 也就是说,我这里的思路是直接用数字来进行处理的,但是这样做其实非常低效而且很容易写错代码,因此我看了下柳婼的代码,换成了这个思路:先将计算结果转换为字符串后进行处理.这样就会简单许多: #include…
PAT 1001 A+B 代码链接:传送门 题目链接:传送门 题目简述: 给定两个值a,b: 范围-1000000 <= a, b <= 1000000: 按指定格式输出a+b的结果,例:-99,991: 解题思路: 一.明确范围 a+b在正负两百万内: int够用,不用高精度: 二.明确格式 三位一起: 视最后采取的代码写法注意可能需要补零: 负号可以提前判定,相当于只要考虑正数: 三.采取措施: 计算a+b的结果c,处理掉负号: 按c按1000进制将结果存储在数组中: 输出最高位: 剩下的…
1001.A+B Format(20) 首先要感谢一下指导我github上传问题的小伙伴们,捣腾了一整天我终于摸到了一点门路,真的谢谢你们. 小豪的github 问题描述: Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digi…
Github : git@github.com:Circlecos/object-oriented.git PDF Of Markdown : "1001. A+B Format (20)" 解题报告 问题描述 Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there…
PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642 题目描述: Calculate a+b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits). 译:计算 a + b 的和,并格式化…
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805528788582400 1001 A+B Format (20 分) Calculate a+b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are le…