描述

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. python学习之self,cls,staticmethod,classmethod

    一.总体说明 python类里会出现这三个单词,self和cls都可以用别的单词代替,类的方法有三种, 一是通过def定义的 普通的一般的,需要至少传递一个参数,一般用self,这样的方法必须通过一个 ...

  2. sgu 194 Reactor Cooling(有容量上下界的无源无汇可行流)

    [题目链接] http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=20757 [题意] 求有容量上下界的无源无汇可行流. [思路] ...

  3. centos编译helloworld的几个小问题

    1.GCC使用在使用GCC编译程序时,编译过程可以被细分为四个阶段:预处理(Pre-Processing)编译(Compiling)汇编(Assembling)链接(Linking).例如:      ...

  4. 关于Aazure 使用以前保留的vhd创建虚拟机的基本步骤

    1. 删除vm保留vhd(只删除虚拟机记录,不删除磁盘)2. 拷贝vhd以及status文件到指定的存储账号3. 使用拷贝的VHD创建disk4. 从disk创建vm,指定指定vnet以及cloud ...

  5. [iOS 多线程 & 网络 - 1.0] - 多线程概述

    A.进程 什么是进程进程是指在系统中正在运行的一个应用程序 每个进程之间是独立的,每个进程均运行在其专用且受保护的内存空间内 比如同时打开QQ.Xcode,系统就会分别启动2个进程 通过"活 ...

  6. dao 获取表最大排序实现

    public Long getMaxOrder(Long parentId) { Query query = this.getSession().createSQLQuery( "selec ...

  7. 山东理工大学ACM平台题答案关于C语言 1137 C/C++经典程序训练7---求某个范围内的所有素数

    C/C++经典程序训练7---求某个范围内的所有素数 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 求小于n的所有素数,按照每行 ...

  8. SAE搭建WordPress教程 免费建WordPress博客站

    SAE搭建WordPress教程 免费建WordPress博客站 WordPress是一种使用PHP语言开发的博客平台,用户可以在支持PHP和MySQL数据库的服务器上架设自己的网志.当然,用户也可以 ...

  9. C#中的where从句

    C#中的where从句 2011-07-03 13:07OrphousV | 分类:C#/.NET | 浏览8443次 能解释一下下面两段代码中where的作用吗?using System;publi ...

  10. jeewx的使用_02 解析微信服务器post过来的数据

    如果在微信公众号接入了第三方的URL,那么用户微信服务器的请求将会被推送到第三方的URL上面,那么该如何解析数据呢?下面来分析 找到MessageUtil.java 这个类中有一个parseXml的静 ...