The 11th Zhejiang Provincial Collegiate Programming Contest->Problem G:G - Ternary Calculation
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3782
题意:把输入的三元运算用计算机运算出来。
1 #include <bits/stdc++.h>
2 using namespace std;
3 int main() {
4 int t;
5 cin>>t;
6 while(t--) {
7 int a,b,c;
8 int s1=;
9 char n,m;
cin>>a>>n>>b>>m>>c;
if(n=='*'||n=='/'||n=='%') {
if(n=='*')
s1=a*b;
else if(n=='/')
s1=a/b;
else
s1=a%b;
if(m=='*')
s1=s1*c;
else if(m=='/')
s1=s1/c;
else if(m=='%')
s1=(int)s1%c;
else if(m=='+')
s1=s1+c;
else if(m=='-')
s1=s1-c;
} else if(m=='*'||m=='/'||m=='%') {
if(m=='*')
s1=b*c;
else if(m=='/')
s1=b/c;
else if(m=='%')
s1=b%c;
if(n=='+')
s1=a+s1;
else if(n=='-')
s1=a-s1;
} else {
if(n=='+')
s1=a+b;
else if(n=='-')
s1=a-b;
if(m=='+')
s1=s1+c;
else if(m=='-')
s1=s1-c;
}
printf("%d\n",s1);
}
return ;
}
The 11th Zhejiang Provincial Collegiate Programming Contest->Problem G:G - Ternary Calculation的更多相关文章
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5503 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Beauty of Array
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5496 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Convert QWERTY to Dvorak
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5502 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest May Day Holiday
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5500 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Demacia of the Ancients
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5504 The 12th Zhejiang Provincial ...
- zjuoj The 12th Zhejiang Provincial Collegiate Programming Contest Ace of Aces
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5493 The 12th Zhejiang Provincial ...
- 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(第二部分)
Floor Function Time Limit: 10 Seconds Memory Limit: 65536 KB a, b, c and d are all positive int ...
- The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - L Doki Doki Literature Club
Doki Doki Literature Club Time Limit: 1 Second Memory Limit: 65536 KB Doki Doki Literature Club ...
随机推荐
- 整合Spring与Hibernate
在学习spring的时候,要整合hibernate,本来是看起来挺简单的,但是遇到的远要比想到了多,而且多很多,期间几天一个bug实在难调,几度放弃,但终究柳暗花明,抑制不住喜悦就想着分享一下成果吧. ...
- fresco的源码学习自我总结
前言 对fresco框架源码的阅读学习,学习优秀的编码方式和较为实用常见设计模式,该篇讲得比较浅,主要是理清三个主要类的之间的关系. 本篇目录 fresco框架的MVC模式 fresco的Drawee ...
- SQL 恢复master数据库方法,没有log文件的数据库文件恢复方法
SQL Server恢复master数据库方法 第一步:复制model.mdf.mastlog.ldf.model.mdf.modellog.ldf.msdbdata.mdf.msdblog.ldf文 ...
- JDBC之数据库操作
JDBC重要界面有: java.sgl.DriverManager:完成驱动程序的装载和建立新的数据库连接. java.sgl.Connection:表示对某一指定数据库的连接. java.sgl.S ...
- 【转】C# 后台开启 cmd执行命令
private void RunCmd(string cmd) { System.Diagnostics.Process p = new System.Diagnostics. ...
- Linux C SMTP POP3 极简陋邮件客户端
以前以为协议非常高神,但做了这个之后发现还好,没想象的那么艰难. 先要了解邮件的原理 再者就是上面2协议 可以先用telnet测试一下,以初步了解那2协议:http://hi.baidu.com/34 ...
- 谈谈Nullable<T>的类型转换问题
本篇文章讨论可空值类型(Nullable<T>)的转换,却确地说是如何将一种类型的值对象转换成相应的可空值.这来源于今天我们的一个成员遇到的一个小问题,我经过一些整理写了这篇文章.虽然没有 ...
- apache 设置禁止访问某些文件或目录
[apache配置禁止访问]1. 禁止访问某些文件/目录增加Files选项来控制,比如要不允许访问 .inc 扩展名的文件,保护php类库:<Files ~ "\.inc$" ...
- php程序备份还原mysql数据库
<?php $link = mysql_connect("localhost", "root",""); mysql_query(&q ...
- [DevExpress]GridControl之CustomColumnDisplayText Helper
在实际开发中,有时候需要对GridControl中列值进行转义,譬如1转义成完成等等,一般在诸如CustomColumnDisplayText事件中能够轻松完成,为了提高代码复用性,所以对Custom ...