백준
백준 5341 - Pyramids(C++)
공대생의 잡다한 사전
2023. 10. 8. 20:46
문제 링크입니다. https://www.acmicpc.net/problem/5341
5341번: Pyramids
The input will be a sequence of integers, one per line. The end of input will be signaled by the integer 0, and does not represent the base of a pyramid. All integers, other than the last (zero), are positive.
www.acmicpc.net

자세한 것은 코드를 참고해주세요.
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <vector>
using namespace std;
int N;
int main() {
cin.tie(0);
cout.tie(0);
while(1){
cin >> N;
if(N == 0) break;
int sum = 0;
for(int i = 1; i <= N; i++) sum += i;
cout << sum << "\n";
}
return 0;
}

질문 및 조언은 댓글을 남겨주세요.