#include <stdio.h>#include<conio.h>int main(){ int i,num1,num2,sum,count; char ch,op; printf("1 2 3 + - \n"); printf("4 5 6 * / \n"); printf("7 8 9 = # \n\n"); { printf("0"); ch=getch(); while(ch<'0' || ch>'9')//输入的不是数字,重新输入 ch=getch(); printf("\b%c",ch); count=1; num1=ch-'0'; while(ch=getch(),ch>='0' && ch<='9') { putchar(ch); num1=num1*10+ch-'0'; count++; } while(1) { op=ch;//符号 ch=getch(); while(ch<'0' || ch>'9')//输入的不是数字,重新输入 ch=getch(); for(i=0;i<count;i++)//回到行首 putchar('\b'); for(i=0;i<count;i++)//用空格覆盖 putchar(' '); for(i=0;i<count;i++)//回到行首 putchar('\b'); putchar(ch); count=1; num2=ch-'0'; while(ch=getch(),ch>='0' && ch<='9') { putchar(ch); num2=num2*10+ch-'0'; count++; } switch(op) { case '+': sum=num1+num2; break; case '-': sum=num1-num2; break; case '*': sum=num1*num2; break; case '/': sum=num1/num2; break; default : break; } for(i=0;i<count;i++)//回到行首 putchar('\b'); for(i=0;i<count;i++)//用空格覆盖 putchar(' '); for(i=0;i<count;i++)//回到行首 putchar('\b'); printf("%d",sum); num1=sum; count=1; while(sum/=10) count++; if(ch=='#') break; } }}