Exercise (3-3) calculation (a + B) * c value, exercise 3-3
Question-exercise (3-3) Calculate (a + B) * c value |
|
|
Source |
Introduction to computing B 2010 |
Description |
Calculates the value of the expression (a + B) * c, where a, B, and c are integers, and a, B, the value of c is between-10000 and 10000 (excluding-10000 and 10000) |
About Input |
Enter only one line, including three integers a, B, and c. |
About output |
The output is also a line, that is, the value of the expression. |
Example Input |
2 3 5 |
Example output |
25 |
|
#include <stdio.h>int main(){ int a, b, c; scanf("%d%d%d", &a, &b, &c); printf("%d\n", (a + b)*c); return 0;} |
If expression a, B, and c respectively indicate three rational numbers and meet the following requirements: | a | = 3, | B | = 1, | c | = 5, | a + B | = a + B, | a + c | =-(a + c) The values of a, B, and c
| A | = 3 a = +-3
| B | = 1 B = +-1
| C | = 5 c = +-5
| A + B | = a + B
A + B> 0
| A + c | =-(a + c)
A + c <0
If a =-3
-3 + (+-1) <0 so a = 3
A + c <0
C <-
C <=-3
C =-5
B cannot be determined +-1
After the C language exercises run the following program, the value of a is, and the value of B is
A = 0;
B = 7;
Resolution:
A = p1 = & m;
Based on the operator priority, the first operation is p1 = & m, the condition is false, the return value is 0, a is int type, and the conversion is int, that is, a = 0;
B = (* p1)/(* p2) + 7;
Directly press the pointer to target, that is, k/m + 7 returns 7.66 ......, B is of the int type, and decimal places are removed during conversion. The result is 7.