문제
정수 n(0 < n < 1000)과 수의 목록이 주어졌을 때, 목록에 들어있는 수가 n의 배수인지 아닌지를 구하는 프로그램을 작성하시오.
입력
첫째 줄에 n이 주어진다. 다음 줄부터 한 줄에 한 개씩 목록에 들어있는 수가 주어진다. 이 수는 0보다 크고, 10,000보다 작다. 목록은 0으로 끝난다.
출력
목록에 있는 수가 n의 배수인지 아닌지를 구한 뒤 예제 출력처럼 출력한다.
예제 입력 1
3 1 7 99 321 777 0 |
예제 출력 1
1 is NOT a multiple of 3. 7 is NOT a multiple of 3. 99 is a multiple of 3. 321 is a multiple of 3. 777 is a multiple of 3. |
더보기
Solution
#include<stdio.h>
int main(void)
{
int n, num;
scanf("%d", &n);
scanf("%d", &num);
while(num!=0)
{
if(num>=n && num%n==0)
printf("%d is a multiple of %d.\n", num, n);
else
printf("%d is NOT a multiple of %d.\n", num, n);
scanf("%d", &num);
}
return 0;
}
728x90
'백준 알고리즘' 카테고리의 다른 글
<백준 알고리즘> 2755번: 이번학기 평점은 몇점? (0) | 2020.10.22 |
---|---|
<백준 알고리즘> 2754번: 학점계산 (0) | 2020.10.22 |
<백준 알고리즘> 15969번: 행복 (0) | 2020.10.22 |
<백준 알고리즘> 13241번: 최소공배수 (0) | 2020.10.22 |
<백준 알고리즘> 5522번: 카드 게임 (0) | 2020.10.22 |