標(biāo)題: 自己做的簡單計算機 雞助的很 用來練習(xí)語法不錯 [打印本頁]

作者: 51黑tt    時間: 2016-3-5 15:48
標(biāo)題: 自己做的簡單計算機 雞助的很 用來練習(xí)語法不錯
#include <stdio.h>-
-
int main(void) {-
    double a, b, c;-
    char flag;-
    int m, n, q, z;-
-
     do {-
     printf("---------------------\n");-
     printf("easy calculator\n");-
     printf("---------------------\n");-
       do {-
       printf("addition input '+', subtraction input '-', multiplication input '*', division input '/'\n");-
       printf("please input you want:")-;
-
       scanf("%c", &flag);-
-
       printf("you input is %c. yes press 1. no press 0 please choose");-
       scanf("%d", &z);-
       } while (0 == z);-
-
      if (flag == '+')-
      m=1;-
-
     else if (flag == '-')-
      m=2;-
-
     else if (flag == '*')-
      m=3;-
-
     else if (flag == '/')-
      m=4;-
-
     do {-
      printf("do a %c b\n",flag);-
      printf("please input a:");-
      scanf("%lf",&a);-
-
      printf("please input b:");-
      scanf("%lf",&b);-
      printf("you want do %lf %c %lf ?? yes input 1, no input 0\n", a, flag, b);-
-
      scanf("%d",&q);-
      } while (0 == q);-
-
      switch (m) {-
       case 1:-
       c=a+b;-
       break;-
-
       case 2:-
       c=a-b;-
       break;-
-
       case 3:-
       c=a*b;-
       break;-
-
       case 4:-
       c=a/b;-
       break;-
       }-
-
     printf("%lf %c %lf=%lf", a, flag, b, c);-
     printf("return? yes input 1, no input 0");-
     scanf("%d", &n);-
     }while (1 == n);-
   return 0;-
}-
    -






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1