The 11th Zhejiang Provincial Collegiate Programming Contest->Problem G:G - Ternary Calculation
来源:互联网 发布:sai for mac 有压感 编辑:程序博客网 时间:2024/06/07 16:41
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3782
题意:把输入的三元运算用计算机运算出来。
#include <bits/stdc++.h>using namespace std;int main() { int t; cin>>t; while(t--) { int a,b,c; int s1=0; 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 0;}
0 0
- The 11th Zhejiang Provincial Collegiate Programming Contest->Problem G:G - Ternary Calculation
- The 11th Zhejiang Provincial Collegiate Programming Contest->Problem G:G - Ternary Calculation
- The 12th Zhejiang Provincial Collegiate Programming Contest - G
- The 7th Zhejiang Provincial Collegiate Programming Contest->Problem G:G - Wu Xing
- The 7th Zhejiang Provincial Collegiate Programming Contest->Problem G:G - Wu Xing
- The 7th Zhejiang Provincial Collegiate Programming Contest - G(Wu Xing)
- The 11th Zhejiang Provincial Collegiate Programming Contest---Talented Chef
- The 11th Zhejiang Provincial Collegiate Programming Contest
- The 11th Zhejiang Provincial Collegiate Programming Contest
- The 11th Zhejiang Provincial Collegiate Programming Contest
- The 11th Zhejiang Provincial Collegiate Programming Contest
- The 11th Zhejiang Provincial Collegiate Programming Contest
- The 11th Zhejiang Provincial Collegiate Programming Contest->Problem A:A - Pokemon Master
- The 11th Zhejiang Provincial Collegiate Programming Contest->Problem A:A - Pokemon Master
- The 7th Zhejiang Provincial Collegiate Programming Contest
- The 6th Zhejiang Provincial Collegiate Programming Contest
- The 8th Zhejiang Provincial Collegiate Programming Contest / L - Javabeans
- The 8th Zhejiang Provincial Collegiate Programming Contest / M - Median
- OpenLayers根据两点连线
- <转> JAVA CAS原理深度分析
- PAT (Top Level) Practise 1001Battle Over Cities - Hard Version (35)
- JAVA笔记整理(1):进制转换
- 读写给大家看的项目管理书
- The 11th Zhejiang Provincial Collegiate Programming Contest->Problem G:G - Ternary Calculation
- 简单选择排序
- Gson 设定固定的日期格式来生成Gson-------Gson 可以将某个对象转换成json,也可将json转换成对象
- free 与 delete
- 《leetCode》:Best Time to Buy and Sell Stock III
- 安装CUDA的风波
- BitmapUtils的相关知识
- Fragment 的静态方式和动态方式以及动态方式中fragment之间通过activity传递 数据(接口回调 ):
- Android主线程、子线程通信(Thread+handler)