描述

szhhck have an old calculator bought 5 years ago.he find the old machine can just calculate expressions like this  :

A-B、A+B、A*B、A/B、A%B.

because it is too old and long time not use,the old machine maybe conclude a wrong answer sometime.

Your task is to write a program to check the answer the old calculator calculates is correct or not.

输入
First input is a single line,it's N and stands for there are N test cases.then there are N lines for N cases,each line contain an equation like A op B = C(A,B and C are all integers,and op can only be + , - , * , / or % ).
More details in the Sample Input.
输出
For each test case,if the equation is illegal(divided or
mod by zero),you should Output "Input Error".and if the equation is
correct,Output "Accept";if not Output "Wrong Answer",and print the right
answer after a blank line.
样例输入
5
1+2=32
2-3=-1
4*5=20
6/0=122
8%9=0
样例输出
Wrong Answer
3
Accept
Accept
Input Error
Wrong Answer
8
 #include <stdio.h>

 int main(){
int T;
int a;
int b;
int c;
char sign; scanf("%d",&T); while(T--){
scanf("%d%c%d=%d",&a,&sign,&b,&c); if(sign=='+'){
if(a+b==c)
printf("Accept\n"); else
printf("Wrong Answer\n%d\n",a+b);
} else if(sign=='-'){
if(a-b==c)
printf("Accept\n"); else
printf("Wrong Answer\n%d\n",a-b);
} else if(sign=='*'){
if(a*b==c)
printf("Accept\n"); else
printf("Wrong Answer\n%d\n",a*b);
} else if(sign=='/'){
if(b==)
printf("Input Error\n"); else if(a/b==c)
printf("Accept\n"); else
printf("Wrong Answer\n%d\n",a/b);
} else if(sign=='%'){
if(b==)
printf("Input Error\n"); else if(a%b==c)
printf("Accept\n"); else
printf("Wrong Answer\n%d\n",a%b);
}
} return ;
}
 

Old Calculator的更多相关文章

  1. [LeetCode] Basic Calculator II 基本计算器之二

    Implement a basic calculator to evaluate a simple expression string. The expression string contains ...

  2. [LeetCode] Basic Calculator 基本计算器

    Implement a basic calculator to evaluate a simple expression string. The expression string may conta ...

  3. Basic Calculator II

    Implement a basic calculator to evaluate a simple expression string. The expression string contains ...

  4. Windows Universal 应用 – Tip Calculator

    声明 以下内容取材于 Bob Tabor 的课程<Windows Phone 8.1 Development for Absolute Beginners>,链接地址为:http://ww ...

  5. Calculator(1.5)

    Calculator(1.5) Github链接 ps.负数的处理未完成 解题过程中遇到的困难和解决 <stack>的使用: 认真研究了栈,基本上掌握了用法,与<queue>的 ...

  6. Calculator(1.0)

    Calculator(1.0) Github链接 解题过程中遇到的困难 对于c++中类和对象的使用不够明确,看了c++的视频教程学会了用类和对象来写程序. 不会使用<queue>,在网上查 ...

  7. 数据结构与算法(1)支线任务2——Basic Calculator

    题目:https://leetcode.com/problems/basic-calculator/ Implement a basic calculator to evaluate a simple ...

  8. calculator

    #include <stdio.h> #include <stdlib.h> typedef enum { FALSE = , TRUE }BOOL; void calcula ...

  9. Basic Calculator

    本博客介绍leetcode上的一道不难,但是比较经典的算法题. 题目如下: Implement a basic calculator to evaluate a simple expression s ...

  10. Matrix Calculator

    表达式分析+矩阵+计算器+寄存器=矩阵计算器 怎么想起来搞这个呢.. //刚看龙书兴致勃勃要搞表达式分析 这个寄存器比较简陋,26字母+4缓存,//字母不分大小写 当然,不只能算矩阵,还能算数= = ...

随机推荐

  1. 测试的rtsp地址

    无线城市 千里眼 http://218.204.223.237:8081/wap/show_video.php?vd=1  右键->复制链接地址即可获得Rtsp地址.

  2. bzoj 3884 上帝与集合的正确用法(递归,欧拉函数)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=3884 [题意] 求2^2^2… mod p [思路] 设p=2^k * q+(1/0) ...

  3. MapReduce Kmeans聚类算法

    最近在网上查看用MapReduce实现的Kmeans算法,例子是不错,http://blog.csdn.net/jshayzf/article/details/22739063 但注释太少了,而且参数 ...

  4. HTML编码

    JavaScript encodeURI() 函数 JavaScript encodeURIComponent() 函数 1.encodeURI: 不编码字符① - _ * . ! ~ ' ( ) ; ...

  5. workstack windows to openstack

    https://www.mirantis.com/openstack-portal/express-openstack-portal/migrating-from-vmware-for-windows ...

  6. HDU 4919 Exclusive or (数论 or 打表找规律)

    Exclusive or 题目链接: http://acm.hust.edu.cn/vjudge/contest/121336#problem/J Description Given n, find ...

  7. HDU 5665 Lucky (水题)

    Lucky 题目链接: http://acm.hust.edu.cn/vjudge/contest/123316#problem/G Description Chaos August likes to ...

  8. jpa仓库接口

    可以使用的仓库接口有: Repository: 是 Spring Data的一个核心接口,它不提供任何方法,开发者需要在自己定义的接口中声明需要的方法. CrudRepository: 继承Repos ...

  9. Hibernate HQL和原生SQL查询的一点区别

    1.createSQLQuery 1.1默认查询的结果为BigDecimal 1.2通过addScalar("CGD_ID", StandardBasicTypes.LONG)可以 ...

  10. OS X Git连接github

    1. 运行到.local 2. cd ~/.ssh查看文件是否存在 3. ssh-keygen(创建public & private key) 4. 或者运行如下命令:cd ~/.ssh &a ...