注意點
1.當結果數組的第1位為0時,注意輸出格式;
2.當被除數小于除數時,結果數組為0,注意輸出格式
#include<stdio.h>
#include<string.h>
int main(){
char num[1001];
int d;
int ans[1001];
while(~scanf("%s%d",&num,&d)){
int j = 0;
int temp = 0;
while(num[j]!='\0'){
temp = temp*10 + (num[j] - '0');
ans[j] = temp/d;
temp = temp%d;
j++;
}
int i = 0;
while(ans[i]==0){
i++;
}
if(i>j){
printf("0");
}else{
while(i<j){
printf("%d",ans[i]);
i++;
}
}
printf(" %d",temp);
}
}