首页 技术 正文
技术 2022年11月14日
0 收藏 740 点赞 2,158 浏览 1160 个字

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;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,082
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,557
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,406
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,179
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,815
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,898