LINK:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3782

题意:给出3个数和两个符号(+-*/%)

思路:拿到题目还以为是要写波兰表达式,仔细一看固定的数和固定的符号,直接if判断好了

  1. /** @Date : 2017-03-23-21.31
  2. * @Author : Lweleth (SoungEarlf@gmail.com)
  3. * @Link : https://github.com/
  4. * @Version :
  5. */
  6. #include<bits/stdc++.h>
  7. #define LL long long
  8. #define PII pair
  9. #define MP(x, y) make_pair((x),(y))
  10. #define fi first
  11. #define se second
  12. #define PB(x) push_back((x))
  13. #define MMG(x) memset((x), -1,sizeof(x))
  14. #define MMF(x) memset((x),0,sizeof(x))
  15. #define MMI(x) memset((x), INF, sizeof(x))
  16. using namespace std;
  17.  
  18. const int INF = 0x3f3f3f3f;
  19. const int N = 1e5+20;
  20. const double eps = 1e-8;
  21.  
  22. int main()
  23. {
  24. int T;
  25. cin >> T;
  26. while(T--)
  27. {
  28. int a, b, c;
  29. char o1[2], o2[2];
  30. int t = 0, ans = 0;
  31. scanf("%d %s%d %s%d", &a, o1, &b, o2, &c);
  32. //cout << a << o1 << b << o2 << c << endl;
  33. if(o1[0] != '*' && o1[0] != '/' && o1[0] != '%' && o2[0] != '+' && o2[0] != '-')
  34. {
  35. if(o2[0] == '*')
  36. t = b * c;
  37. else if(o2[0] == '/')
  38. t = b / c;
  39. else if(o2[0] == '%')
  40. t = b % c;
  41. if(o1[0] == '+')
  42. t = a + t;
  43. else if(o1[0] == '-')
  44. t = a - t;
  45. }
  46. else
  47. {
  48. if(o1[0] == '+')
  49. t = a + b;
  50. else if(o1[0] == '-')
  51. t = a - b;
  52. else if(o1[0] == '*')
  53. t = a * b;
  54. else if(o1[0] == '/')
  55. t = a / b;
  56. else if(o1[0] == '%')
  57. t = a % b;
  58.  
  59. if(o2[0] == '+')
  60. t = t + c;
  61. else if(o2[0] == '-')
  62. t = t - c;
  63. else if(o2[0] == '*')
  64. t = t * c;
  65. else if(o2[0] == '/')
  66. t = t / c;
  67. else if(o2[0] == '%')
  68. t = t % c;
  69. }
  70. //cout << 5 % 8 % 2 << endl;
  71. printf("%d\n", t);
  72. }
  73. return 0;
  74. }

ZOJ 3782 G - Ternary Calculation 水的更多相关文章

  1. The 11th Zhejiang Provincial Collegiate Programming Contest->Problem G:G - Ternary Calculation

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3782 题意:把输入的三元运算用计算机运算出来. ;          ci ...

  2. Ternary Calculation

    Ternary Calculation Time Limit : /2000ms (Java/Other) Memory Limit : /65536K (Java/Other) Total Subm ...

  3. ZOJ 3778 C - Talented Chef 水题

    LINK:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3778 题意:有n道菜,每道菜需要\(a_i\)道工序,有m个锅可 ...

  4. Codeforces Beta Round #10 A. Power Consumption Calculation 水题

    A. Power Consumption Calculation 题目连接: http://www.codeforces.com/contest/10/problem/A Description To ...

  5. 暑假训练Round1——G: Hkhv的水题之二(字符串的最小表示)

    Problem 1057: Hkhv的水题之二 Time Limits:  1000 MS   Memory Limits:  65536 KB 64-bit interger IO format: ...

  6. ZOJ 3959 Problem Preparation 【水】

    题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3959 AC代码 #include <cstdio> ...

  7. ZOJ 3958 Cooking Competition 【水】

    题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3958 AC代码 #include <cstdio> ...

  8. zoj 3827 Information Entropy 【水题】

    Information Entropy Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Information ...

  9. ZOJ 1796 Euchre Results 数学水题

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1796 题意: 四个人玩游戏,已知三个人的输赢情况,求第四个人的输赢情况. ...

随机推荐

  1. Saver 保存与读取

    tensorflow 框架下的Saver 功能,用以保存和读取运算数据 Saver 保存数据 代码 import tensorflow as tf # Save to file #remember t ...

  2. DP---基本思想 具体实现 经典题目 POJ1160 POJ1037

    POJ1160, post office.动态规划的经典题目.呃,又是经典题目,DP部分的经典题目怎就这么多.木有办法,事实就这样. 求:在村庄内建邮局,要使村庄到邮局的距离和最小. 设有m个村庄,分 ...

  3. 七周七语言之用Io编写领域特定语言

    如果你想获得更好的阅读体验,可以前往我在 github 上的博客进行阅读,http://lcomplete.github.io/blog/2013/06/05/sevenlang-io/. Io 语言 ...

  4. 【leetcode】215. Kth Largest Element in an Array

    Find the kth largest element in an unsorted array. Note that it is the kth largest element in the so ...

  5. (五)hadoop系列之__集群搭建SSH无密访问多台机器

    免密码ssh设置 现在确认能否不输入口令就用ssh登录localhost: $ ssh localhost 如果不输入口令就无法用ssh登陆localhost,执行下面的命令: . 并修改hosts映 ...

  6. C# 委托和事件高级进阶

    本篇文章主要采用理论和代码实例相结合方式来论述委托和事件,涉及到一些边界技术,如软件架构的OCP原则(开-闭原则), 软件架构解耦,设计模式(Sender-Order)和事件驱动模型,有一定难度和深度 ...

  7. ie浏览器升级的正确姿势

    一.版本说明 1.当前IE浏览器分为一下几个版本:IE 6,IE 7,IE 8,IE 9,IE 10,IE 11 2.windows最高支持IE版本win xp:IE 8win 7 :IE 11win ...

  8. 【Django】Django迁移数据库

    我们已经编写了博客数据库模型的代码,但那还只是 Python 代码而已,Django 还没有把它翻译成数据库语言,因此实际上这些数据库表还没有真正的在数据库中创建 为了让 Django 完成翻译,创建 ...

  9. java面试及答案

    优秀总结博客 mybatis总结 java并发包相关 一.Java基础 1.String类为什么是final的. 2.HashMap的源码,实现原理,底层结构. hashmap3.反射中,Class. ...

  10. WordPress忘记密码找回登录密码的四种行之有效的方法

    WordPress忘记密码找回登录密码的四种行之有效的方法 PS:20170214更新,感谢SuperDoge同学提供的方法,登入phpMyAdmin后,先从左边选自己的数据库,然后点上面的 SQL ...