https://www.acmicpc.net/problem/8393
8393번: 합
n이 주어졌을 때, 1부터 n까지 합을 구하는 프로그램을 작성하시오.
www.acmicpc.net
#include <iostream>
using namespace std;
int main()
{
int n, cnt;
cnt = 0;
cin >> n;
for(n; n>0; n--){
cnt += n;
}
cout << cnt << endl;
return 0;
}
'‡ CODING TEST STUDY ‡ > º 백준' 카테고리의 다른 글
[백준 2407번] 조합 (0) | 2023.08.26 |
---|---|
[백준 11653번] 소인수분해 (0) | 2023.08.25 |
[백준 14916번] 거스름돈 (0) | 2023.08.01 |
[백준 9498번] 시험 성적 (0) | 2023.08.01 |
[백준 8958번] OX퀴즈 (0) | 2023.08.01 |