C언어
문제 : 임의의 숫자를 입력받고 임의의 숫자에 3이란 숫자가 몇개 있는지 출력하시오.
#include <stdio.h>
int count_3(int x)
{
int count=0;
while(1)
{
if(x%10==3)
count++;
x/=10;
if(x==0)
break;
}
return count;
}
int main()
{
int put,count;
scanf("%d",&put);
count = count_3(put);
printf("%d",count);
}
return 0;
'C language' 카테고리의 다른 글
C language - 문자 두개를 입력 받고 순서대로 출력 (0) | 2016.05.27 |
---|---|
C language - 임의의 수를 입력받아 수의 역수 출력하기 (0) | 2016.05.27 |
C language - 10진수를 입력 받고 8진수 16진수로 표현하기 (1) | 2016.05.21 |