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 ...
随机推荐
- ms08_067利用过程
进入msf. show exploits. use exploit/windows/smb/ms08_067_netapi. show playloads. set PLAYLOAD windows/ ...
- 使用Three.js渲染Sketchup导出的dae
打算做个轮盘游戏,直接上3D吧. 第一步:制作模型 3DMax和Maya下载和破解比较麻烦, 就用之前的Sketchup来试试吧. 最后效果图: 俯视图 仰视图 制作步骤: 1 先画一个圆 2 从圆心 ...
- MySQL中文乱码修改
一.从服务端进行修改 show variables like "%char%"; 然后可能显示如下信息,注意红色部分,不同的用户可能实际情况不同,但是需要保证除了 filesyst ...
- django 中文乱码问题
在使用JS 发送ajax到django后台的时候,可能会出现中文乱码问题 解决方案: 所有的HTMl 和py文件都使用utf-8编码,在创建数据库的时候指定使用utf8 :create databas ...
- jQuery Mobile 自定义按钮图标
自定义css样式---红色部分必须加上 .ui-icon-user-black:after {background:url('../image/user-black.png') no-repeat 0 ...
- html中的空白字符问题
1.当我们想使用百分比来进行两个盒子的并排 代码: <!DOCTYPE html> <html lang="en"> <head> <me ...
- dom操作js
1.getElementById()//ie8下不区分大小写 getElementsByName()//name属性相比于Id可以不唯一,且其只在表单.表单元素.img .iframe中有用,返回一个 ...
- Linux内核源代码目录树结构
Linux内核源代码目录树结构. arch:包含和硬件体系结构相关的代码,每种平台占一个相应的目录.和32位PC相关的代码存放在i386目录下,其中比较重要的包括kernel(内核核心部分).mm(内 ...
- Building Your First EDM
1 文件--新建--项目 控制台应用程序,填写信息,确定: 2 在解决方案管理器中,选中AmyConsoleApp,添加新项, 选择ADO.NET 实体数据模型,添加: 3 在选择模型内容中选择“从数 ...
- 18、手把手教你Extjs5(十八)模块记录的拖放删除、拖放复制新增
网页当中的拖放(drag-drop)是比较有趣的操作,extjs5中很好的封装了拖放的动作,也有各种类来支持,但是要学好“拖放”这个东西真是很难,特别是象我这样英语不好的人,看不太懂官网上的说明,做一 ...