C/C++ Programming Learning-Week 6① Calculate A+B (Novice Course)

Topic link

Title description

Open the door to a new world, start by passing this question! ヽ(●´∀`●)ノ

Enter two integers A and B to calculate the result of A+B.

You need to write a program to input two integers A and B from standard input, and then output the result of A+B to standard output. For example, the standard input and output methods in C language are scanf and printf, and the standard input and output methods in C++ are cin and cout.

Note: Do not output any redundant auxiliary information, for example, the following C program is unnecessary.

#include <stdio.h>
int main() { int A, B; printf("Please enter two integers:\n"); scanf("%d %d", &A, &B); printf("A + B = %d\n”, A + B); return 0; } The correct way of writing is






#include <stdio.h>
int main() { int A, B; scanf("%d %d", &A, &B); printf("%d\n", A + B); return 0; } Submit Later you will get the following possible results.





Congratulations on passing this question: The output produced by your program is exactly the same as the reference output, but there is no guarantee that the algorithm is completely correct.
Program compilation error: Your program cannot be compiled.
Incorrect operation result: The output result of your program is incorrect, which means that your program did not get the result we expected.
Program running timeout: Your program tries to use more than the time limit of the title, it may be that your program has an infinite loop or the algorithm efficiency of your program is too low.
Program runtime error: A runtime error occurred in your program, which may be due to runtime problems such as division by 0 and memory access violations.
Program memory limit exceeded: Your program tried to use more memory than the problem limit.
Program output exceeds the limit: the output of your program exceeds the limit, please check whether your program has an infinite loop problem.
System error: Unknown error, if there is the evaluation result, please contact the staff in time.
common problem:

Question: What kind of example is the input is correct but the submission returns the wrong result?

Answer: Each question in the question bank has a large amount of test data in the background, and this question can only be passed by passing all the test data in the background.

Q: Why can't I see the test data?

Answer: The question bank does not provide specific information about the background test data, only the number of passing data sets.

If you have more questions about the environment, you can check the FAQ, or join the QQ group 642061140 to learn together.

Input format The
input is one line, including two integers A and B separated by spaces (1≤A, B≤1000).

Output format The
output is one line, the result of A+B.

Sample Input

5 7

Sample Output

12

Ideas

There is an answer on the question.

C language code:

#include<stdio.h>
int main()
{
    
    
	int a, b;
	scanf("%d%d", &a, &b);
	return 0;
}

C++ code:

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

Guess you like

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