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. android使用Intent操作拨打号码发送短信

    Activity程序Activity.java package com.example.intentcaseproject; import android.net.Uri; import androi ...

  2. 第三十一篇、iOS 9版本适配

    1.网络适配(强制回退HTTP) 为了强制增强数据访问安全, iOS9 默认会把 所有的http请求 所有从NSURLConnection . CFURL . NSURLSession发出的 HTTP ...

  3. Swift泛型和泛型函数

    泛型(generic)可以使我们在程序代码中定义一些可变的部分,在运行的时候指定.使用泛型可以最大限度地重用代码.保护类型的安全以及提高性能.在Swift集合类中,已经采用了泛型.一.一个问题的思考怎 ...

  4. CoreAnimation 核心动画二 锚点

    锚点: anchorPoint     以锚点为中心 执行动画 (与 渔夫固定船的点时一致的) anchorPoint 默认是 0.5,0.5  (注意: 锚点 是一个比例) anchorPoint ...

  5. 利用图层的mask属性裁剪图形

    需求如上图. 代码如下 //充值 UIButton *rechargeButton = [[UIButton alloc] initWithFrame:CGRectMake(, , , )]; [re ...

  6. MyEclipse导入ant项目——Java编程思想

    北门煎饼东门串儿: <JAVA编程思想(Think in Java)>一书中提供了大量源代码,可是项目是用ant构建的.对于用惯了eclipse,netbeans等IDE的同学们可能有些手 ...

  7. 洛谷 P1508 Likecloud-吃、吃、吃

    P1508 Likecloud-吃.吃.吃 题目提供者JosephZheng 标签 动态规划 难度 普及/提高- 题目背景 问世间,青春期为何物? 答曰:"甲亢,甲亢,再甲亢:挨饿,挨饿,再 ...

  8. ASP.net中导出Excel的简单方法介绍

    下面介绍一种ASP.net中导出Excel的简单方法 先上代码:前台代码如下(这是自己项目里面写的一点代码先贴出来吧) <div id="export" runat=&quo ...

  9. Android 使用日常

    如何让Android Studio的智能感知不区分大小写? http://ask.csdn.net/questions/155844

  10. Jquery get parameter value

    http://www.sitepoint.com/url-parameters-jquery/ $.urlParam('id') ==> $.urlParam = function(name){ ...