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 ...
随机推荐
- HOWTO: Be more productive
---by Aaron Swartz HOWTO: Be more productive “With all the time you spend watching TV,” he tells m ...
- 第一篇、Swift_搭建UITabBarController + 4UINavigationController主框架
import UIKit class MainViewController: UITabBarController { override func viewDidLoad() { super.view ...
- Ajax和JSON基础
Ajax (核心是XMLHttpRequest对象) 1.XMLHttpRequest对象: request=new XMLHttpRequest() 支持Firefox opera Safari ...
- 学习红帽企业版RHEL 6.4的两问
(1)看了一晚上的RHEL 6.4,到现在也没分清楚服务器版和桌面版.都说两个版本是一个文件,那装上之后怎么判断这到底用的是服务器版还是桌面版?还有人说在安装过程中会要求选择,用虚拟机安装根本没看到有 ...
- memset与NULL区别
memset与NULL区别 NULL与0 的区别 为什么强调一个malloc对应一个free 在一个结构体malloc,然后free,但是她的成员变量的malloc并没有free,还需要特别的free ...
- 菜鸟级asp.net 与ms sql server数据库打交道的简单总结
using System.Data.SqlClient;using System.Data; 上面是必须的 下面说的都是用存储过程 首先是webconfig里面的连接字符串: <connecti ...
- 实现cookie跨域访问
需求:A系统(www.a.com)里设置一个浏览器cookie,B系统(www.b.com)需要能够访问到A设置的cookie. 通过HTML SCRIPT标签跨域写cookie: 由于html的sc ...
- 【NetOffice Excel】Excel合并单元格【原】
CSharp操作Excel采用开源的原生.NET程序集NetOffice,格式兼容性更好. 在操作Excel的时候有时候需要合并单元格 using ExcelOffice = NetOffice.Ex ...
- C# CRC32
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa ...
- 九度OJ1172--哈夫曼树
哈夫曼树,第一行输入一个数n,表示叶结点的个数.需要用这些叶结点生成哈夫曼树,根据哈夫曼树的概念,这些结点有权值,即weight,题目需要输出所有结点的值与权值的乘积之和. 输入: 输入有多组数据.每 ...