Created
September 15, 2015 06:13
-
-
Save sifue/5849d68919bd7746bb73 to your computer and use it in GitHub Desktop.
C++で標準出力から得た数値を足し算するだけのもの
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <string> | |
| #include <vector> | |
| #include <cstdlib> | |
| #include <typeinfo> | |
| using namespace std; | |
| int main() | |
| { | |
| string str; | |
| vector<int> data(5); | |
| int sum = 0; | |
| while (getline(cin, str)) | |
| { | |
| cout << "[" << str << "]" << endl; | |
| data.push_back(atoi(str.c_str())); | |
| } | |
| cout << "Input finished." << endl; | |
| for (int i = 0; i < data.size(); ++i) { | |
| sum += data[i]; | |
| } | |
| cout << "Sum=" << sum << endl; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment