資源簡介
用C語言實現補碼的除法。推導無符號整數與補碼的乘或算算法,進行理論推導論證。討論各種算法并進行算法分析。
代碼片段和文件信息
/*
?============================================================================
?Name????????:?除法.c
?Author??????:?
?Version?????:?1.0
?Copyright???:?Your?copyright?notice
?Description?:?實現補碼的除法
?============================================================================
?*/
#include?
#include?
int?main(void)?{
??????int??xyXY;???????????????????//x是被除數,y是除數
??int??y1_longy2_longz;?????????//y1_long是+Y,y2_long是-Y?
??????int?iknumremainderquotient;????//remainder是余數,quotient是商?
?????char?u[16];
?????printf(“please?enter?the?dividend?and?divisor:?“);
?????scanf(“%d?%d“&x&y);???????//輸入被除數和除數?
?????X=x;
?Y=y;
??
?if(y==0){???????????????????//若除數是0,錯誤?
? printf(“wrong!\n“);
? return;
? ??}
?????if(x==0){???????????????????//若被
評論
共有 條評論