1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | //PART1 Challenge Q2 #include <stdio.h> int gugu(int v1, int v2) { if(v1 < v2) { int i,j; for(i=v1; i<=v2; i++) { for(j=1; j<10; j++ ) printf("%d x %d = %d\n",i,j,i*j); } } else { int i,j; for(i=v2; i<=v1; i++) { for(j=1; j<10; j++ ) printf("%d x %d = %d\n",i,j,i*j); } } } int main(void) { int v1,v2; printf("2개의 정수를 입력하시오: "); scanf("%d %d",&v1,&v2); gugu(v1,v2); } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | //PART1 Challenge Q3 #include <stdio.h> int uc(int v1, int v2) { int i,max; if(v1 > v2) max = v1; else if(v1 < v2) max = v2; for(i=2; i<max; i++) { if(v1 % i == 0 && v2 % i == 0) printf("두 수의 최대공약수: %d",i); } } int main(void) { int v1,v2; printf("두개의 정수 입력: "); scanf("%d %d",&v1,&v2); uc(v1,v2); } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | //PART1 Challenge Q4 #include <stdio.h> int choice(int coin) { } int main(void) { int coin = 3500; int crim = 500; int shirimp = 700; int cola = 400; printf("현재 당신이 소유하고 있는 금액 : %d\n",coin); choice(coin); } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | //PART1 Challenge Q5 #include <stdio.h> int prime(void) { int i=1,j=1,k=0; for(j=1; j<50; j++) { for(i=1; i<50; i++) { if(j % i == 0) { k++; } if(i == 48) { if(k == 2) { printf("%d ",j); } k=0; break; } } } } int main() { prime(); } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | //PART1 Challenge Q6 #include <stdio.h> int caltime(int val) { int time=0,minute=0,second=0,jjam; if(val <= 60) { printf("[h:%d , m:%d, s:%d]",time,minute,val); } else if(val <= 3600) { minute = val / 60; jjam = val % 60; printf("[h:%d , m:%d, s:%d]",time,minute,jjam); } else { time = val / 3600; jjam = val % 3600; minute = jjam / 60; jjam = jjam % 60; printf("[h:%d , m:%d, s:%d]",time,minute,jjam); } } int main(void) { int second; printf("초(second) 입력: "); scanf("%d",&second); caltime(second); } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | //PART1 Challenge Q7 #include <stdio.h> int getk(int n) { int k=0,i,val=2; for(i=1;i<30;i++) { printf("%d\n",val); if(val <= n) k++; val *= 2; } printf("공식을 만족하는 k의 최댓값은 %d\n",k); } int main(void) { int n; printf("상수 n 입력: "); scanf("%d",&n); getk(n); } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | //PART1 Challenge Q8 #include <stdio.h> int getval(int n,int v1) { int val; val = v1 * 2; n--; printf("%d %d\n",n,v1); if(n == 0) return v1; getval(n,val); } int main(void) { int val,get; printf("정수 입력: "); scanf("%d",&val); get = getval(val,2); printf("2의 %d승은 %d",val,get); } | cs |