본문 바로가기

알고리즘문제3

C- ACM - 소수판정 반복문 { flag = 0 or 1; result= result * falg; } 보다 깔끔한.. 함수사용의 효율성을 배울 수 있었던 문제. 함수 { { if(...){return 0;} } return 1; } "아빠가 한번 안된다고 하면 안되는거야!"라는 의미ㅎ 1 보다 큰 정수 P 가 1 과 P 자신 이외의 양의 약수를 가지지 않을 때의 P 를 소수라고 부른다. 이를테면, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 등은 모두 소수이다. 4, 6, 16 등과 같이 소수가 아니면서 2 이상인 자연수를 합성수라고 정의하며, 1 은 소수도 아니고 합성수도 아닌 수이다. 주어진 자연수 N 이 소수인지 아닌지를 판정하라. 입력 표준 입력(standard input)을 통하여 입력한다.. 2010. 6. 9.
C- ACM - 문자열 도도도 도시라~ 글자를 찾는 모습이 마치., 젓가락 행진곡 같지 않나요? ㅋㅋㅋ (도도도 도레미~) #include #include int main (void) { char input_char[1000]; int i_temp=NULL; int repeat=NULL; scanf("%d",&repeat); if(repeat10){printf("Only input range '1-10'\n");return 0;} for(int k=0; k 2010. 6. 8.
C- ACM - Coin 으음.. 막상 이해하고 나면 /이게 뭐야/ 할지도 ㅋㅋ In Korea, there are four kinds of coins – a 10-won coin, a 50-won coin, 100-won coin and a 500-won coin. Given K 10-won coins, L 50-won coins, M 100-won coins and N 500-won coins, you are to write a program that calculate the total amount. Input The input consists of T test cases. The number of test cases T is given in the first line of the input file. Each test ca.. 2010. 6. 8.