A + B Problem
Description
A + B Problem
Calculate a + b
Standard Input
Two integer a, b.
Standard Output
Output a + b
Samples
| Input | Output |
|---|---|
| 1 2 | 3 |
| 2 3 | 5 |
| 5 6 | 11 |
Constraints
0 a, b 10
Soulution
From the problem, we need to calculate the sum of two integers, the two input integers are less than or equal to 10. We can choose the unsigned int variable to store the two integers, and then output their sum
#include <iostream>
using namespace std;
int main(void)
{
unsigned short a, b;
cin >> a >> b;
cout << a + b;
return 0;
}
Summary
I feel that using unsigned short doesn’t seem to make much difference from int.