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的更多相关文章

  1. 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 ...

  2. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...

  3. 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 ...

  4. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

  10. 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 ...

随机推荐

  1. html 文件动态加载.PDI 流程图

    1 //javascript脚本 <script> window.onload = function () { var aid = document.getElementById(&quo ...

  2. PYTHON:HTTP头设置工具(以附件名为例)

    import oss2 # 用户授权 auth = oss2.Auth('accessId', 'accessKey')# oss bucket bucket = oss2.Bucket(auth, ...

  3. lstm-思想2

    LSTM 网络 Long Short Term 网络—— 一般就叫做 LSTM ——是一种 RNN 特殊的类型,可以学习长期依赖信息.LSTM 由 Hochreiter & Schmidhub ...

  4. 资源汇集:nginx教程从入门到精通

    http://linux.cn/article-4279-1.html

  5. 项目中的那些事---PHP函数

    总结工作中遇到的php函数: 1.查找:strpos("str", "substr"): 查找substr字符串在str字符串中出现的位置 第一个参数是:被查找 ...

  6. AngularJS开发相关配置

    安装步骤: 1. Node.js,下载地址:https://nodejs.org/en/ 2. Git 下载地址:https://git-scm.com/download/ 3. Python (需为 ...

  7. 关于Fragment的使用与Androikd sdk版本之间的东东

    第一个问题如何使用Fragment? 第二个问题哪些场景适合用Fragment? 第三个问题android.app.fragment与android.support.v4.app.Fragment 为 ...

  8. 关于TCP的两个小练习_第一个博客~

    先来一个本地的,客户端发送请求,服务端接收请求的简单代码 1 package com.TCP.java; 2 3 import java.io.IOException; 4 import java.i ...

  9. Centos6.5网络无法连接问题

    1. 先进入对应文件夹: cd /etc/sysconfig/network-scripts/ 2.获取root权限: su     然后输入root密码 3.修改ifcfg-eth0 vi ifcf ...

  10. DTcms 扩展字段标签调用

    前台模版: 文章列表:{dr[author]} 文章内容{model.fields[author]} 点击数 后台CS文件:model.fields["author"].ToStr ...