NYOJ 486 Old Calculator
来源:互联网 发布:lol数据分析 编辑:程序博客网 时间:2024/05/18 18:01
Old Calculator
时间限制:1000 ms | 内存限制:65535 KB
难度:1
- 描述
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.
- 样例输入
51+2=322-3=-14*5=206/0=1228%9=0
- 样例输出
Wrong Answer3AcceptAcceptInput ErrorWrong Answer8
思路:略
#include<stdio.h>int main(){int m;scanf("%d",&m);while(m--){int a,b,sum;char ch;scanf("%d%c%d=%d",&a,&ch,&b,&sum);switch(ch){case '+':if (a+b == sum){printf("Accept\n");}else{printf("Wrong Answer\n%d\n",a+b);}break;case '-':if (a-b == sum){printf("Accept\n");}else{printf("Wrong Answer\n%d\n",a-b);}break;case '*':if (a*b == sum){printf("Accept\n");}else{printf("Wrong Answer\n%d\n",a*b);}break;case '/':if (b == 0){printf("Input Error\n");}else{if (a/b == sum){printf("Accept\n");}else{printf("Wrong Answer\n%d\n",a/b);}}break;case '%':if (b == 0){printf("Input Error\n");}else{if (a%b == sum){printf("Accept\n");}else{printf("Wrong Answer\n%d\n",a%b);}}break;}}}
0 0
- NYOJ 486 Old Calculator
- nyoj-486-Old Calculator
- NYOJ 486题 Old Calculator
- Old Calculator
- Old Calculator
- Calculator
- Calculator
- Calculator
- Calculator
- Calculator
- Calculator
- calculator
- Calculator
- Calculator
- calculator
- Calculator
- Calculator
- Calculator| ||
- Java.lang.throwable源代码
- AIX误删/etc/passwd 进行的一次恢复操作
- 隐藏 select 边框和三角
- 设计模式C++实现(5)——原型模式、模板方法模式
- html页面中改变TAB键的切换顺序
- NYOJ 486 Old Calculator
- Filter与Listener使用案例
- MTK代码全集
- ListView滚动条压到item内容
- 开发外包注意事项——iOS APP的开发
- BootStrap思想
- 设计模式C++实现(6)——建造者模式
- python-Levenshtein几个计算字串相似度的函数解析
- 使用JQuery中AJAX的几种方法