<<Input and Output>> _HakerRank_C++_Introduction

#include <cmath>#include <cstdio>#include <vector>#include <iostream>#include <algorithm>using namespace std;int main() {    /* Enter your code here. Read input from STDIN. Print output to STDOUT */      int a, b, c ;        cin >> a >> b >> c ;    cout << a + b + c << endl ;         return 0;}

Objective
In this challenge, we practice reading input from stdin and printing output to stdout.


In C++, you can read a single whitespace-separated token of input using cin, and print output to stdout using cout. For example, let's say we declare the following variables:

string s;
int n;

and we want to use cin to read the input "High 5" from stdin. We can do this with the following code:
cin >> s >> n;

This reads the first word ("High") from stdin and saves it as string s, then reads the second word ("5") from stdin and saves it as integer n. If we want to print these values to stdout, separated by a space, we write the following code:
cout << s << " " << n << endl;

This code prints the contents of string s, a single space (" "), then the integer n. We end our line of output with a newline using endl. This results in the following output:
High 5

Task
Read 3 numbers from stdin and print their sum to stdout.

Input Format
One line that contains 3 space-separated integers: a, b, and c.

Constraints
1<= a, b, c, <= 1000

Output Format
Print the sum of the three numbers on a single line.

Sample Input
1 2 7

Sample Output
10

Explanation
The sum of the three numbers is 1 + 2 + 7 =10.


关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章