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. Git CMD - mv: Move or rename a file, a directory, or a symlink

    命令格式 git mv [-v] [-f] [-n] [-k] <source> <destination> git mv [-v] [-f] [-n] [-k] <so ...

  2. 抽象类[abstract]_C#

    抽象类(abstract) abstract修饰符可以和类.方法.属性.索引器及事件一起使用.在类声明中使用abstract修饰符以指示某个类只能是其它类的基类.标记为抽象或包含在抽象类中的成员必须通 ...

  3. 2014-10 u-boot make xxx_defconfig 过程分析

    /** ****************************************************************************** * @author    Maox ...

  4. WCF、WebAPI、WCF REST、Web Service之间的区别

    在.net平台下,有大量的技术让你创建一个HTTP服务,像Web Service,WCF,现在又出了Web API.在.net平台下,你有很多的选择来构建一个HTTP Services.我分享一下我对 ...

  5. btrace 实践笔记

    btrace简介:     btrace 是一个使用在JAVA平台上面的,安全的,动态跟踪工具.它一般用于动态跟踪正在运行的jAVA程序.     使用说明在这里.下载地址在这里.     下载的时候 ...

  6. JavaScript笔记(二)——常用数组、字符串方法的应用

    1.将字符串中的字符翻转,比如'hello',翻转成'olleh'. var arr=[]; function reverseString(str) { arr=str.split("&qu ...

  7. Windows api 函数全部列表 (未完成)

    网上找了很久,发现没有完整版的,msdn上面有,但是不方便查阅,所以想自己整理一下:由于工程量过于庞大,希望大家共同完成.MSDN:http://msdn.microsoft.com/en-us/li ...

  8. ISO-9126 软件质量模型

    摘要 在软件开发过程中,软件的质量是一个重要的因素,而软件体系结构在整个过程中显得尤为重要.软件的质量需求是在开发初期的非功能性需求,对软件的体系结构影响很大.但是并不意味着一味的追求质量,必须在效率 ...

  9. Java单例模式--------懒汉式和饿汉式

    单件模式用途:单件模式属于工厂模式的特例,只是它不需要输入参数并且始终返回同一对象的引用.单件模式能够保证某一类型对象在系统中的唯一性,即某类在系统中只有一个实例.它的用途十分广泛,打个比方,我们开发 ...

  10. win8安装python环境和pip & easy_install工具

    最近在学python,2.7.6的版本 首先安装python2.7 官网下载地址https://www.python.org/downloads/ 下载相应版本即可,应该是一个msi的文件,默认安装到 ...