HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Arithmetic > problem:


50335 - Five Math Operators

Guest
• Review clarifications (1)

Section problems

• 50641 - Strong Prime Power
• 50249 - Ladders
• 50247 - Missing numbers
• 50267 - Interesting permutations
• 50640 - Cubes
• 50377 - kth Permutation
• 50341 - Separate Into Digits
• 50424 - Area
• 50335 - Five Math Operators
• 50299 - Median
• 50301 - Fractions to Decimals
• 50304 - Number Pattern
• 50305 - John's Tasks
• 50649 - Puzzle
• 50321 - Missing Number
• 50308 - IT Knowledge Seminars
• 50310 - Kinetic Energy

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 4000/7000/7000/7000 ms. Memory limit 65000/65000/65000/65000 Kb.
bfs.

Five Math Operators

  Write a program that gets two integers and an operator from the keyboard and then does described operation using the given numbers.

  There are five operations:

  • '+' Addition: adds the second number to the first number
  • '-' Subtraction: Subtracts the second number from the first number
  • '*' Multiplication: Multiplies the first and the second numbers
  • '/' Integer division: Divides the first number by the second number producing integer result
  • '%' Modulus: Gives the remainder when the first number is divided by the second number

Input specification
  First, you will be given a number (n where 1 ≤ n ≤ 10). Then, each of the following n lines will contain an integer followed by a char and another integer: (e.g. 5+3). Char will be one of five operators (+, -, *, /, %) and the integers will be positive and less than 1000.

Output specification
  Show one number for every operation (line) which is the result of the given operator with the given numbers.

Sample Input:
  4
  45+20
  20-30
  7%3
  99/10

Sample Output:
  65
  -10
  1
  9


Для отправки решений необходимо выполнить вход.

www.contester.ru