天天看點

結對程式設計項目四則運算

小組成員:李铖  130201209   李靜遠  130201210

源代碼

#include "stdio.h"void main(){int x,y,result;float temp;char oprand,flag='Y';while(flag=='Y'||flag=='y'){do{printf("請輸入四則運算式子\n");scanf("%d%c%d",&x,&oprand,&y);if(oprand!='+'&&oprand!='-'&&oprand!='*'&&oprand!='/')printf("Input error\n");}while(oprand!='+'&&oprand!='-'&&oprand!='*'&&oprand!='/');switch(oprand){case '+':result=x+y;printf("result=%d\n",result);break;case '-':result=x-y;printf("result=%d\n",result);break;case '*':result=x*y;printf("result=%d\n",result);break;case '/':if(y==0)printf("Divisor can not be 0\n");else {temp=(float)x;printf("result=%f\n",temp/y);}break;}getchar();printf("結束運算Y/y or N/n\n");scanf("%c",&flag);}}

結對程式設計項目四則運算

總結:

這次作業完成後,可以實作基本的加減乘除,支援負數,分數,有括号。最多可以出現三個運算符。在合作的過程中,我主要負責編寫代碼,李靜遠主要負責查找和詢問。我的優點是對作業比較上心,可以及時向周圍的同學詢問,态度積極。缺點是知識掌握的不好。李靜遠的優點是會一些基礎的代碼,邏輯思維較為缜密,态度積極。缺點是知識掌握的不牢固。在合作的過程中,可以結合兩個人的優缺點來完成作業,起到互補的作用。但是有些時候會意見不同。

結對程式設計項目四則運算