zoj-3782-Ternary Calculation
题目链接
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5269
题目很简单,直接把所有情况列出来。
我的AC代码
#include<stdio.h>
int main()
{
int t;
int a,b,c;
char c1,c2;
int s;
scanf("%d",&t);
getchar();
while(t--)
{
scanf("%d",&a);
getchar();
scanf("%c",&c1);
scanf("%d",&b);
getchar();
scanf("%c",&c2);
scanf("%d",&c);
getchar();
if(c1=='*')
{
if(c2=='*')
s=a*b*c;
else if(c2=='/')
s=a*b/c;
else if(c2=='%')
s=a*b%c;
else if(c2=='+')
s=a*b+c;
else
s=a*b-c;
}
else if(c1=='/')
{
if(c2=='*')
s=a/b*c;
else if(c2=='/')
s=a/b/c;
else if(c2=='%')
s=a/b%c;
else if(c2=='+')
s=a/b+c;
else
s=a/b-c;
}
else if(c1=='%')
{
if(c2=='*')
s=a%b*c;
else if(c2=='/')
s=a%b/c;
else if(c2=='%')
s=a%b%c;
else if(c2=='+')
s=a%b+c;
else
s=a%b-c;
}
else if(c1=='+')
{
if(c2=='*')
s=a+b*c;
else if(c2=='/')
s=a+b/c;
else if(c2=='%')
s=a+b%c;
else if(c2=='+')
s=a+b+c;
else
s=a+b-c;
}
else
{
if(c2=='*')
s=a-b*c;
else if(c2=='/')
s=a-b/c;
else if(c2=='%')
s=a-b%c;
else if(c2=='+')
s=a-b+c;
else
s=a-b-c;
}
printf("%d\n",s);
}
return 0;
}
也可以利用栈的知识。
zoj-3782-Ternary Calculation的更多相关文章
- Ternary Calculation
Ternary Calculation Time Limit : /2000ms (Java/Other) Memory Limit : /65536K (Java/Other) Total Subm ...
- ZOJ 3782 G - Ternary Calculation 水
LINK:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3782 题意:给出3个数和两个符号(+-*/%) 思路:拿到题目还 ...
- The 11th Zhejiang Provincial Collegiate Programming Contest->Problem G:G - Ternary Calculation
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3782 题意:把输入的三元运算用计算机运算出来. ; ci ...
- 2012-2014 三年浙江 acm 省赛 题目 分类
The 9th Zhejiang Provincial Collegiate Programming Contest A Taxi Fare 25.57% (166/649) (水 ...
- 浙大月赛ZOJ Monthly, August 2014
Abs Problem Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Alice and Bob is playing a ga ...
- ZOJ People Counting
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ 3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...
- [LeetCode] Ternary Expression Parser 三元表达式解析器
Given a string representing arbitrarily nested ternary expressions, calculate the result of the expr ...
- ZOJ 3686 A Simple Tree Problem
A Simple Tree Problem Time Limit: 3 Seconds Memory Limit: 65536 KB Given a rooted tree, each no ...
- Ternary Expression Parser
Given a string representing arbitrarily nested ternary expressions, calculate the result of the expr ...
- OpenCASCADE Curve Length Calculation
OpenCASCADE Curve Length Calculation eryar@163.com Abstract. The natural parametric equations of a c ...
随机推荐
- Java中的字符串分割 .
转自 http://blog.csdn.net/yuwenhao0518/article/details/7161059 http://longkm.blog.163.com/blog/static/ ...
- VHD容量调整的方法(保存原有vhd)
VHD容量调整的方法(保存原有vhd)特别对于RAMOS的VHD,调整VHD容量的办法:1.在WIN7或者7PE中,右击我的电脑→管理→磁盘管理,挂载原始VHD文件,然后新建一个VHD文件,初始化,格 ...
- mysql 字符集配置
查看和设置MySQL数据库字符集作者:scorpio 2008-01-21 10:05:17 标签: 杂谈 Liunx下修改MySQL字符集:1.查找MySQL的cnf文件的位置find / -ina ...
- Spring创建对象的方式3种方式
此文为基础回顾,估计是最后一次总结. 项目利用maven进行架构,其基本项目结构为: 其中pom.xml中的内容为: <project xmlns="http://maven.apac ...
- Size Balanced Tree(SBT) 模板
首先是从二叉搜索树开始,一棵二叉搜索树的定义是: 1.这是一棵二叉树: 2.令x为二叉树中某个结点上表示的值,那么其左子树上所有结点的值都要不大于x,其右子树上所有结点的值都要不小于x. 由二叉搜索树 ...
- 打造最强Windows Server 2012 给你比Windows 8更好的体验
每一代微软桌面操作系统推出的时候,都会同步推出相应核心的服务器操作系统,稳定性会更强哈 所以改造一下,让它保留兼容和专业的同时又有桌面操作系统的美观和便捷,多好 咳咳,让我们来看看怎么把Server ...
- hibernate和ibatis的区别
通过别人的资料,进行自己关注的一些扼要点的整理 共同点: 1. 不同点:1. 自动化程度上,hibernate是全自动化的orm框架,提供了对象到数据库的完全映射和sql的内部自动生成,其对象映射是指 ...
- SpringMVC轻松学习-其他常用(四)
Spring MVC 3.0 深入 核心原理 1. 用户发送请求给服务器.url:user.do 2. 服务器收到请求.发现DispatchServlet可以处理.于是调用Disp ...
- POJ 2653 Pick-up sticks
计算几何,判断线段相交 注意题目中的一句话:You may assume that there are no more than 1000 top sticks. 我认为是没有描述清楚的,如果不是每次 ...
- nginx keepalived 主从切换
注: LVS + Keepalived 不知道为什么出现一个很郁闷的问题....... ------------------------------------------------------ ...