-
백준 10951번 A+B_4백준 algorithm 2020. 7. 9. 12:18반응형
https://www.acmicpc.net/submit/10951/20817704
로그인
www.acmicpc.net
벡터를 이용해서 푼 경우
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 <vector> using namespace std; int main(void) { int x = 0, y = 0; vector<int> result; while (cin >> x >> y) { result.push_back(x + y); cout << result[0]<<"\n"; result.clear(); } /*for (int i = 0; i < result.size(); i++) { cout << result[i] << "\n"; } return 0;*/ } cout으로 바로 출력 한경우
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 <vector> using namespace std; int main(void) { int x = 0, y = 0; vector<int> result; while (cin >> x >> y) { //result.push_back(x + y); cout << x + y << "\n"; } /*for (int i = 0; i < result.size(); i++) { cout << result[i] << "\n"; } return 0;*/ } | while(cin>>a>>b)
입력받는 경우에 대해 while문을 돌리고 싶은 경우의 조건
728x90'백준 algorithm' 카테고리의 다른 글
백준 5543번 상그날드 (0) 2020.07.15 백준 10039번 (0) 2020.07.15 백준 15552번 빠른 A+B (0) 2020.07.08 백준 2741 번 N 찍기 (0) 2020.07.08 백준 2742번 기찍 N (0) 2020.07.08