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

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

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

/** @Date    : 2017-03-23-21.31
* @Author : Lweleth (SoungEarlf@gmail.com)
* @Link : https://github.com/
* @Version :
*/
#include<bits/stdc++.h>
#define LL long long
#define PII pair
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std; const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8; int main()
{
int T;
cin >> T;
while(T--)
{
int a, b, c;
char o1[2], o2[2];
int t = 0, ans = 0;
scanf("%d %s%d %s%d", &a, o1, &b, o2, &c);
//cout << a << o1 << b << o2 << c << endl;
if(o1[0] != '*' && o1[0] != '/' && o1[0] != '%' && o2[0] != '+' && o2[0] != '-')
{
if(o2[0] == '*')
t = b * c;
else if(o2[0] == '/')
t = b / c;
else if(o2[0] == '%')
t = b % c;
if(o1[0] == '+')
t = a + t;
else if(o1[0] == '-')
t = a - t;
}
else
{
if(o1[0] == '+')
t = a + b;
else if(o1[0] == '-')
t = a - b;
else if(o1[0] == '*')
t = a * b;
else if(o1[0] == '/')
t = a / b;
else if(o1[0] == '%')
t = a % b; if(o2[0] == '+')
t = t + c;
else if(o2[0] == '-')
t = t - c;
else if(o2[0] == '*')
t = t * c;
else if(o2[0] == '/')
t = t / c;
else if(o2[0] == '%')
t = t % c;
}
//cout << 5 % 8 % 2 << endl;
printf("%d\n", t);
}
return 0;
}

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. struts常量<constant>说明

    1.<constant name="struts.action.extension" value="do" />这个时候访问action都必须加.d ...

  2. ERROR----java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils

    2013-4-28 13:17:57 org.apache.catalina.core.StandardContext filterStart 严重: Exception starting filte ...

  3. unrecognized selector send to instancd 快速定位

    1.在Debug菜单中Breakpoints->Create Symbolic Breakpoint; 2.在Symbolic中填写方法签名: -[NSObject(NSObject) does ...

  4. HDU 5265 pog loves szh II 二分

    题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5265 bc(中文):http://bestcoder.hdu.edu.cn/contests ...

  5. webService —— soap

    package soupTest; import javax.jws.WebMethod; import javax.jws.WebService; import javax.xml.ws.Endpo ...

  6. Struts2(六)

    以下内容是基于导入struts2-2.3.32.jar包来讲的 1.OGNL OGNL是Object-Graph Navigation Language的缩写,全称为对象图导航语言,是一种功能强大的表 ...

  7. ASP.NET存储Session的StateServer

    由于公司要对服务器做个负载均衡,所以Web项目在两台前端服务器(web1.web2)各部署了一份.但是在项目中会用到session.当一开始在web1上登陆后,由于web1之后负载可能会变大,就有可能 ...

  8. SQL Server 怎样生成序列号(虚拟数字辅助表)

    </pre><pre name="code" class="sql">--生成一个"序列" 或者说生成一个" ...

  9. jmeter同步定时器

    同步定时器是jmeter中一个比较重要的定时器,同步定时器,相当于一个储蓄池,累积一定的请求,当在规定的时间内达到一定的线程数量,这些线程会在同一个时间点一起并发,可以用来做大数据量的并发请求. 验证 ...

  10. P4551 最长异或路径

    题目描述 给定一棵 nnn 个点的带权树,结点下标从 111 开始到 NNN .寻找树中找两个结点,求最长的异或路径. 异或路径指的是指两个结点之间唯一路径上的所有边权的异或. 输入输出格式 输入格式 ...