题目 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…
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 pa…
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 的和,并格式化…
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 pa…
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) Sample Input: -1000000 9 Sample Output: -999,991 第一种方法,注意题目说明的数字范围,及时处理越界即可. 为啥捏,因为 in…
题意:给两个整数a,b,计算a+b的值并每三位用逗号隔开输出(−1e6​​≤a,b≤1e6​​) AAAAAccepted code: #include<bits/stdc++.h> using namespace std; int main(){ int a,b; cin>>a>>b; int ans=a+b; ){ cout<<"-"; ans=-ans; } ; ; ; ; if(yy){ cout<<yy<<…
AC代码 #include <cstdio> #include <algorithm> using namespace std; const int maxn = 11; int main() { #ifdef ONLINE_JUDGE #else freopen("1.txt", "r", stdin); #endif // ONLINE_JUDGE long long a, b; scanf("%lld %lld",…
题目: 我一开始的思路是: 用math.h中的log10函数来计算位数(不建议这么做,因为会很慢,而且会出一点别的问题): 用pow函数根据要插入分号的位置来拆分a+b成一个个数字(例如res / pow(10, len - 3)来获得千位以前的数字),从左往右依次输出,同时在对应位置输出,: 也就是说,我这里的思路是直接用数字来进行处理的,但是这样做其实非常低效而且很容易写错代码,因此我看了下柳婼的代码,换成了这个思路:先将计算结果转换为字符串后进行处理.这样就会简单许多: #include…
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…