-
11718번,11719번,11720번백준알고리즘/입출력 2020. 10. 1. 22:34
11718번
#include<iostream> #include<string> using namespace std; int main(void) { string str; while (1) { getline(cin, str); if (str == "\0") { break; } else { cout << str << endl; } } }
11719번
#include<iostream> #include<string> using namespace std; int main(void) { int i = 1; string str; while (i<=100) { getline(cin, str); cout << str << endl; i++; } }
11720번
#include<iostream> #include<string> using namespace std; int main(void) { int n = 0; cin >> n; char a; int sum = 0; for (int i = 0; i < n; i++) { cin >> a; sum = sum + (a - 48); } cout << sum; }
공백입출력 string,char
#include<iostream> #include<string> using namespace std; int main(void) { string a; getline(cin, a); cout << a << endl; char b[100]; cin.getline(b, 100); cout << b; }