[Thinking] Divide R and count down the remainder to achieve base conversion, and use the do...while loop to avoid the need to separately judge the value of zero.
#include <stdio.h> #include <stdlib.h> intmain () { int A,B,D,sum,a[100]; scanf("%d%d%d",&A,&B,&D); sum = A+B; int i=0; do{ a[i++] = sum%D; sum = sum/D; }while(sum!=0); for(int j=i-1;j>=0;j--){ printf("%d",a[j]); } return 0; }