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 (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…
1001 A+B Format (20)(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). Input Each input file contains one test case. Each case…
1001 A+B Format (20)(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). Input Each input file contains one test case. Each case…
1001. A+B Format (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue 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 d…