POJ C Programming Problem # # #: operator determination

Source: Internet
Author: User

Programming Question #: operator determination

Source: POJ (Coursera statement: The exercises completed on POJ will not count against the final results of Coursera. )

Note: Total time limit: 1000ms memory limit: 65536kB

Describe

After two integers a and b are calculated, the result is C. Expressed as: a? b = C, where,? may be addition +, subtraction-, multiplication *, divisible/or residual%. Determine the operator based on the value of the input a,b,c. If an operation is established, the corresponding operator is output, and if no operation is established, the error is output.

For example:

Input:

3,4,5

Output:

Error

If you enter:

3,4,3

The output:

%

Input

Values of a B and C take care of inline input, with a comma interval

Output

One of the five operators or an error

Sample input
6,7,13
Sample output
+
1#include <stdio.h>2#include <iostream>3 4 intMain ()5 {6     intA, B, C;7scanf"%d,%d,%d",&a,&b,&c);8     if(a+b==c)9     {Tenprintf"+"); One}Else if(a-b==c) A     { -printf"-"); -}Else if(a*b==c) { theprintf"*"); -}Else if(b!=0&&a/b==c) -     { -printf"/"); +}Else if(b!=0&& a%b==c) -     { +printf"%c",'%'); A}Else { atprintf"Error"); -     } -     return 0; -}

POJ C Programming Problem # # #: operator determination

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.