The subject requires a A/b, where A is a positive integer that does not exceed 1000 bits, and B is a 1-bit positive integer. You need to output the quotient Q and the remainder r so that a = B * Q + R is set up.
Input format:
The input is given a and B in 1 rows, and the middle is separated by 1 spaces.
Output format:
In 1 rows, output Q and R in turn, separated by 1 spaces in the middle.
#include <stdio.h> #include <stdlib.h> #include <string.h> #define N 1001int Main () { char str1[n+1 ],str2[n+1],cha; scanf ("%s%c", Str1,&cha); int chu=cha-' 0 ', Beichu=0,shang=0,yushu=0;//chushu int Length=strlen (STR1), I; for (i=0;i<length;i++) { beichu=str1[i]-' 0 ' +yushu*10; Shang=beichu/chu; Yushu=beichu%chu; str2[i]=shang+ ' 0 '; } str2[i]= ' + '; Length=strlen (STR2); for (i=0;i<length;i++) { if (i==0 && (str2[i]-' 0 ') ==0) if (length>1) continue; printf ("%c", Str2[i]); } printf (""); printf ("%d\n", Yushu); System ("pause"); return 0; }
1017. A divided by B