D进制的A+B (12)
#include <stdio.h>
typedef long long int;
int main(){
int A,B,C,D;
int z[31],num=0;
scanf("%d %d %d",&A,&B,&D);
C=A+B;
do{
z[num++]=C%D;
C=C/D;
}while(C!=0);
for(int i=num-1;i>=0;i--)
printf("%d",z[i]);
return 0;
}
A+B和C (01)
#include <stdio.h>
int main(){
int n;
long long A,B,C;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%lld %lld %lld",&A,&B,&C);
printf("Case #%d: %s\n",i+1,(A+B)>C?"true":"false");
}
return 0;
}
部分A+B (16)
#include <stdio.h>
int main(){
int D1,D2,P1=0,P2=0;
long long A,B;
scanf("%lld %d %lld %d",&A,&D1,&B,&D2);
while(A){
if(A%10==D1)
P1=10*P1+D1;
A=A/10;
}
while(B){
if(B%10==D2)
P2=10*P2+D2;
B=B/10;
}
printf("%d\n",P1+P2);
return 0;
}