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). Input Specification: Each input file contains one test case. Eac
#include<iostream> #include<cstdio> using namespace std; int m,n; int main() { while(scanf("%d%d",&m,&n) !=EOF){ if(m%n==0) cout<<"YES"<<endl; else cout<<
两数相加,结果每三位添加一个逗号。一开始没有注意到%03d的问题,因为有某些数据逗号分割后高位带0,因此需要用0来补充空位。 1 #include<iostream> 2 #include<stdio.h> 3 using namespace std; 4 int main(){ 5 int a,b; 6 scanf("%d%d",&a,&b); 7 int sum=a+b;
题集通道:https://pintia.cn/problem-sets/994805342720868352/problems/type/7 A1001 : A+B Format (20 point(s)) 解这道题的关键是题目所给的条件: - 10e6 <= a,b <= 10e6,所以a+b最多为7位数。 代码如下: 1 #include <cstdio> 2 #include <iostream> 3 #include <cstdl
判断一个数是否能被另一个整数整除是一个挺简单的问题,一般一个模运算就可以搞定了,懒惰的晓萌还是不想自己做,于是找到你帮他写代码,你就帮帮他吧。 输入格式 输入包括两个由空格分开的整数 MM 和 N(1\leq M,N \leq 500)N(1≤M,N≤500)。 输出格式 输出包括一行,如果 MM 可以
思路: 数字范围可以用int型, 先进行计算,然后利用string型进行处理; 最前方部分特殊处理,之后部分按逗号+数字的格式输出。 #include <iostream> #include <string> using namespace std; int main(){ int a, b; cin >> a >> b; int sum = a + b; if (sum < 0) cout