#include #include #include char tmp1[100], tmp2[100], tmpans[200]; char op1[100], op2[100], ans[200]; int scale1,scale2, scale3, len1, len2, len3; void removeblank(char*); void scale(char*op1, int&, int&); void reverse(char x[]); void adjust(); void printans(), add(), sub(), mul(), div(); int main(){ printf("First#:"); gets(tmp1); printf("Second#:"); gets(tmp2); removeblank(tmp1); removeblank(tmp2); strcpy(op1, tmp1); strcpy(op2, tmp2); scale(op1, scale1, len1); scale(op2, scale2, len2); printf("scal1=%d\n", scale1); printf("scal2=%d\n", scale2); reverse(op1); reverse(op2); adjust(); printf("op1=%s\n", op1); printf("op2=%s\n", op2); printf("scal1=%d\n", scale1); printf("scal2=%d\n", scale2); add(); printans(); sub(); printans(); mul(); printans(); div(); printans(); } void removeblank(char x[1]) { } void scale(char x[1], int&n, int&len) { char*p; n=0; len = strlen(x); if(NULL== (p=strchr(x,'.')) ) return; n= len - ( p - x) -1; len--; // exclude the "." } void reverse(char x[1]) { char tmp[100], i, k=0; for(i=strlen(x)-1; i>=0; i--){ if(x[i] != '.') tmp[k++] = x[i] ; } tmp[k]=0; strcpy(x, tmp); } void adjust() { int i,n; if(scale1==scale2)return; if(scale1>scale2){ n= scale1 - scale2; for(i=len2-1; i>=0; i--) op2[i+n] = op2[i]; for(i=0; i=0; i--) op1[i+n] = op1[i]; for(i=0; i