Old Calculator
- 描述
-
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的更多相关文章
- [LeetCode] Basic Calculator II 基本计算器之二
Implement a basic calculator to evaluate a simple expression string. The expression string contains ...
- [LeetCode] Basic Calculator 基本计算器
Implement a basic calculator to evaluate a simple expression string. The expression string may conta ...
- Basic Calculator II
Implement a basic calculator to evaluate a simple expression string. The expression string contains ...
- Windows Universal 应用 – Tip Calculator
声明 以下内容取材于 Bob Tabor 的课程<Windows Phone 8.1 Development for Absolute Beginners>,链接地址为:http://ww ...
- Calculator(1.5)
Calculator(1.5) Github链接 ps.负数的处理未完成 解题过程中遇到的困难和解决 <stack>的使用: 认真研究了栈,基本上掌握了用法,与<queue>的 ...
- Calculator(1.0)
Calculator(1.0) Github链接 解题过程中遇到的困难 对于c++中类和对象的使用不够明确,看了c++的视频教程学会了用类和对象来写程序. 不会使用<queue>,在网上查 ...
- 数据结构与算法(1)支线任务2——Basic Calculator
题目:https://leetcode.com/problems/basic-calculator/ Implement a basic calculator to evaluate a simple ...
- calculator
#include <stdio.h> #include <stdlib.h> typedef enum { FALSE = , TRUE }BOOL; void calcula ...
- Basic Calculator
本博客介绍leetcode上的一道不难,但是比较经典的算法题. 题目如下: Implement a basic calculator to evaluate a simple expression s ...
- Matrix Calculator
表达式分析+矩阵+计算器+寄存器=矩阵计算器 怎么想起来搞这个呢.. //刚看龙书兴致勃勃要搞表达式分析 这个寄存器比较简陋,26字母+4缓存,//字母不分大小写 当然,不只能算矩阵,还能算数= = ...
随机推荐
- 瞬间从IT屌丝变大神——分工安排
分工安排主要包含以下内容: 公共组件(包括common.css和common.js)一人维护,各子频道专人负责,每个频道正常情况下由一人负责,要详细写明注释,如多人合作,维护的人员注意添加注释信息,具 ...
- How to fix “X: user not authorized to run the X server, aborting.”? -摘自网络
This is just a simple tips to solve a error message when you start your X session with “startx” comm ...
- snprintf 返回值
在平时写代码的过程中,我一个推荐带有n系列的字符串函数,如 strcat ->strncat sprintf->snprintf 我们有类似的一个函数 void dump_kid(std: ...
- Spring Auto scanning components
Normally you declare all the beans or components in XML bean configuration file, so that Spring cont ...
- 四轴飞行diy全套入门教程(从最基础的开始)
转载:http://www.cnmox.com/thread-12460-1-1.html首先声明本人也是菜鸟,此教程就是从一个菜鸟的角度来讲解,现在论坛上的帖子都突然冒很多名词出来,又不成体系,我自 ...
- Android流量监控 思路,想法
1,开启一个服务,每5分钟跑动一次更新流量,用于能够准确记录流量 每一个小时,更新一次流量,用于清除非本月的流量 2,保存流量的时候,进行判断 a,若是数据库中保存的 ...
- Unity3D之Mecanim动画系统学习笔记(五):Animator Controller
简介 Animator Controller在Unity中是作为一种单独的配置文件存在的文件类型,其后缀为controller,Animator Controller包含了以下几种功能: 可以对多个动 ...
- 【Java】IO技术的使用——用IO实现大文件的复制
转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/5827481.html 用IO进行文件复制,实质就是用FileInputStream链接要复制的文件,按一定规模 ...
- 用Swashbuckle给ASP.NET Core的项目自动生成Swagger的API帮助文档
博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:用Swashbuckle给ASP.NET Core的项目自动生成Swagger的API帮助文档.
- 哥也能写KMP了——实现strstr()
经过上次去面试,面试官要求实现strstr(),当场就蒙了.这个题目是模式匹配问题,<算法导论>里列出了几种字符串匹配算法: 朴素算法 | Rabin-Karp | 有限自动机算法 | ...