找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2166|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

自己做的簡單計(jì)算機(jī) 雞助的很 用來練習(xí)語法不錯

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:107189 發(fā)表于 2016-3-5 15:48 | 只看該作者 回帖獎勵 |倒序?yàn)g覽 |閱讀模式
#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;-
}-
    -

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表