CS计算机代考程序代写 #include

#include
#include “DIVEMU.h”

int main(int argc, char** argv){
uint32_t A = 43;
uint32_t B = 7;
divuRet unsignedResult=emulatedDivu(A,B);
fprintf(stdout, “A = %u, B = %u, A/B = \n”,A, B, unsignedResult.quotient, unsignedResult.remainder);
B = 0;
unsignedResult=emulatedDivu(A,B);
fprintf(stdout, “A = %u, B = %u, A/B = \n”,A, B, unsignedResult.quotient, unsignedResult.remainder);
A = 7;
B= 43;
unsignedResult=emulatedDivu(A,B);
fprintf(stdout, “A = %u, B = %u, A/B = \n”,A, B, unsignedResult.quotient, unsignedResult.remainder);
A = 24;
B= 7;
unsignedResult=emulatedDivu(A,B);
fprintf(stdout, “A = %u, B = %u, A/B = \n”,A, B, unsignedResult.quotient, unsignedResult.remainder);
int32_t C = 18;
int32_t D = 2;
divRet signedResult=emulatedDiv(C,D);
fprintf(stdout, “C = %d, D = %d, C/D = – verify: C=Q*D+R — %d = %d * %d + %d | %d==%d?\n”,C, D, signedResult.quotient, signedResult.remainder,C, signedResult.quotient, D, signedResult.remainder,C,signedResult.quotient*D+signedResult.remainder);
C = -18;
D = -2;
signedResult=emulatedDiv(C,D);
fprintf(stdout, “C = %d, D = %d, C/D = – verify: C=Q*D+R — %d = %d * %d + %d | %d==%d?\n”,C, D, signedResult.quotient, signedResult.remainder,C, signedResult.quotient, D, signedResult.remainder,C,signedResult.quotient*D+signedResult.remainder);
C = -18;
D = 2;
signedResult=emulatedDiv(C,D);
fprintf(stdout, “C = %d, D = %d, C/D = – verify: C=Q*D+R — %d = %d * %d + %d | %d==%d?\n”,C, D, signedResult.quotient, signedResult.remainder,C, signedResult.quotient, D, signedResult.remainder,C,signedResult.quotient*D+signedResult.remainder);
C = 18;
D = -2;
signedResult=emulatedDiv(C,D);
fprintf(stdout, “C = %d, D = %d, C/D = – verify: C=Q*D+R — %d = %d * %d + %d | %d==%d?\n”,C, D, signedResult.quotient, signedResult.remainder,C, signedResult.quotient, D, signedResult.remainder,C,signedResult.quotient*D+signedResult.remainder);
C = 18;
D = 4;
signedResult=emulatedDiv(C,D);
fprintf(stdout, “C = %d, D = %d, C/D = – verify: C=Q*D+R — %d = %d * %d + %d | %d==%d?\n”,C, D, signedResult.quotient, signedResult.remainder,C, signedResult.quotient, D, signedResult.remainder,C,signedResult.quotient*D+signedResult.remainder);
C = -18;
D = -4;
signedResult=emulatedDiv(C,D);
fprintf(stdout, “C = %d, D = %d, C/D = – verify: C=Q*D+R — %d = %d * %d + %d | %d==%d?\n”,C, D, signedResult.quotient, signedResult.remainder,C, signedResult.quotient, D, signedResult.remainder,C,signedResult.quotient*D+signedResult.remainder);
C = -18;
D = 4;
signedResult=emulatedDiv(C,D);
fprintf(stdout, “C = %d, D = %d, C/D = – verify: C=Q*D+R — %d = %d * %d + %d | %d==%d?\n”,C, D, signedResult.quotient, signedResult.remainder,C, signedResult.quotient, D, signedResult.remainder,C,signedResult.quotient*D+signedResult.remainder);
C = 18;
D = -4;
signedResult=emulatedDiv(C,D);
fprintf(stdout, “C = %d, D = %d, C/D = – verify: C=Q*D+R — %d = %d * %d + %d | %d==%d?\n”,C, D, signedResult.quotient, signedResult.remainder,C, signedResult.quotient, D, signedResult.remainder,C,signedResult.quotient*D+signedResult.remainder);
return 0;
}