1017. A除以B

    xiaoxiao2021-03-25  135

    题目链接:https://www.patest.cn/contests/pat-b-practise/1017

     

    #include<stdio.h> #include<string.h> char A[1010]; int main(){   int B;   scanf("%s%d",A,&B);   int sum=0;   int len=strlen(A);   if(len==1&&A[0]-'0'<B)   printf("0 %d\n",A[0]-'0');   else{   for(int i=0;i<len;i++){    sum=sum*10+A[i]-'0';    if(sum>=B)    printf("%d",sum/B);      if(sum<B&&i!=0)    printf("0");    sum=sum%B;       }   printf(" %d\n",sum);   }   return 0; }

    转载请注明原文地址: https://ju.6miu.com/read-11673.html

    最新回复(0)