测试点1:天坑,如果被除数只有一位并且还没有除数大,那么就应该输出0 被除数,例如: 5 7,输出 0 5(不是0 7哦)!!!!!
#include <stdio.h>
#include <string.h>
int main(){
char a[1001];
int res[1001];
int top = 0;
int b,i,temp,c=0;
scanf("%s %d",a,&b);
int len = strlen(a);
if(len==1&&(a[0]-'0')/b==0){
printf("0 %c",a[0]);
return 0;
}
for(i=0;i<len;i++){
temp = (a[i]-'0')+10*c;
if(temp/b==0){
c = temp;
if(top!=0){
res[top++] = 0;
}
}else{
res[top++] = temp/b;
c = temp%b;
}
}
for(i=0;i<top;i++){
printf("%d",res[i]);
}
printf(" %d",c);
}