C語言源碼: [cpp] #include<stdio.h> int main() { int m,a,b,s[100],k,top; scanf("%d",&m); while(m) { scanf("%d %d",&a,&b); k=0; top=0; if(a==0&b==0) s[top++]=0; else while(a!=0||b!=0||k!=0) { s[top++]=(a%m+b%m+k)%m; k=(a%m+b%m+k)/m; a/=m; b/=m; } for(k=top-1;k>=0;k--) printf("%d",s[k]); printf("\n"); scanf("%d",&m); } }