找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2144|回复: 0
收起左侧

自己做的简单计算机 鸡助的很 用来练习语法不错

[复制链接]
ID:107189 发表于 2016-3-5 15:48 | 显示全部楼层 |阅读模式
#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;-
}-
    -

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表