准备三月份的PAT记录每天的题解
PAT甲级1001
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
freopen("pat0314/in.txt","r",stdin);
int a,b;
cin>>a>>b;
int c = a + b;
if(c < 0)
{
printf("-");
c = -c;
if(c < 1000)
{
printf("%d",c);
}
else if(c >= 1000 && c < 1000000)
{
int temp = c /1000;
printf("%d,",temp);
printf("%03d",c % 1000);
}
else
{
int temp = c / 1000000;
printf("%d,",temp);
int temp1 = c % 1000000 / 1000;
printf("%03d,",temp1);
int temp2 = c % 1000;
printf("%03d",temp2);
}
}
else
{
if(c < 1000)
{
printf("%d",c);
}
else if(c >= 1000 && c < 1000000)
{
int temp = c /1000;
printf("%d,",temp);
printf("%03d",c % 1000);
}
else
{
int temp = c / 1000000;
printf("%d,",temp);
int temp1 = c % 1000000 / 1000;
printf("%03d,",temp1);
int temp2 = c % 1000;
printf("%03d",temp2);
}
}
return 0;
}