C/C++ Programming Learning-Week 7② Calculate the value of (a+b)/c

Topic link

Title description

The garlic master has prepared another formula for you. Come and see how the division is.

Given three integers a, b, c, calculate the value of the expression (a+b)/c, and / is the division operation.

Input format
Input only one line, including three integers a, b, c, the number and the number are separated by a space. (−10,000≤a,b,c≤10,000,c≠0)

Output format
Output one line, that is, the value of the expression.

Sample Input

1 1 3

Sample Output

0

Ideas

Similar to the previous question, according to the requirements of the question, to calculate the value of (a+b)*c, only addition and division are needed.

C language code:

#include <stdio.h>
int main()
{
    
    
	long long a, b, c;
	scanf("%ld%ld%ld", &a, &b, &c);
	long long sum = (a + b) / c;
	printf("%ld", sum);
	return 0;
}

C++ code:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    
	int a, b, c;
	while(cin >> a >> b >> c)
		cout << (a + b) / c << endl;
	return 0;
}

For students who don’t have C language foundation, you can learn the C language grammar first. I will sort it out and send it out later.
I have already written it. You can go to the C language programming column to see the content of the first week .

Other exercises this week:

C language programming column

C/C++ Programming Learning-Week 7① Calculate the value of (a+b)*c

C/C++ Programming Learning-Week 7② Calculate the value of (a+b)/c

C/C++ Programming Learning-Week 7 ③ Kakutani Conjecture

C/C++ programming learning-week 7④ cocktail therapy

C/C++ Programming Learning-Week 7 ⑤ The number of the same number as the specified number

C/C++ Programming Learning-Week 7 ⑥ Group photo effect

C/C++ Programming Learning-Week 7⑦ Word Flip

Guess you like

Origin blog.csdn.net/qq_44826711/article/details/112912010