♕Bronze Ⅲ
문제
자연수 N이 주어졌을 때, 1부터 N까지 한 줄에 하나씩 출력하는 프로그램을 작성하시오.
입력
첫째 줄에 100,000보다 작거나 같은 자연수 N이 주어진다.
출력
첫째 줄부터 N번째 줄 까지 차례대로 출력한다.
C
#include <stdio.h> int main() { int N, result = 1; scanf("%d",&N); while(result <= N){ printf("%d\n",result); result++; } return 0; }
Python 1
N = int(input()) result = 1 while result <= N: print(result) result += 1
Python 2
N = int(input()) for i in range(1,N+1): print(i)
파이썬으로도 풀어봤는데 훨씬 간단하다.
잠시 쉬어가는 킬링타임용