diff --git a/Soyoung/5-1.c b/Soyoung/5-1.c new file mode 100644 index 0000000..7e816aa --- /dev/null +++ b/Soyoung/5-1.c @@ -0,0 +1,17 @@ +#include + +int factorial(int n) { + if( n==0 || n== 1 ) { + return 1; + } + else { + return n * factorial(n-1); + } +} + +int main() { + int N; + scanf("%d", &N); + printf("%d", factorial(N)); + return 0; +} \ No newline at end of file diff --git a/Soyoung/5-2.c b/Soyoung/5-2.c new file mode 100644 index 0000000..fd7fcf5 --- /dev/null +++ b/Soyoung/5-2.c @@ -0,0 +1,14 @@ +#include + +char i_letter(char *S, int i) { + return S[i-1]; +} + +int main() { + char S[1000]; + scanf("%s", S); + int i; + scanf("%d", &i); + printf("%c", i_letter(S, i)); + return 0; +} \ No newline at end of file diff --git a/Soyoung/5-3.c b/Soyoung/5-3.c new file mode 100644 index 0000000..260462e --- /dev/null +++ b/Soyoung/5-3.c @@ -0,0 +1,17 @@ +#include + +int main() { + int T; + scanf("%d", &T); + for(int i=0;i + +int main() { + int N; + scanf("%d", &N); + + int min = 1000000; + int max = -1000000; + + for (int i = 0; i < N; i++) { + int num; + scanf("%d", &num); + + if (num < min) { + min = num; + } + if (num > max) { + max = num; + } + } + printf("%d %d\n", min, max); + return 0; +} \ No newline at end of file diff --git a/Soyoung/7_2.c b/Soyoung/7_2.c new file mode 100644 index 0000000..ea8de6d --- /dev/null +++ b/Soyoung/7_2.c @@ -0,0 +1,21 @@ +#include + +int main() { + while (1) { + int a, b; + scanf("%d %d", &a, &b); + + if (a == 0 && b == 0) { + break; + } + if (b % a == 0) { + printf("factor\n"); + } else if (a % b == 0) { + printf("multiple\n"); + } else { + printf("neither\n"); + } + } + + return 0; +} diff --git a/Soyoung/7_3.c b/Soyoung/7_3.c new file mode 100644 index 0000000..e8f7353 --- /dev/null +++ b/Soyoung/7_3.c @@ -0,0 +1,24 @@ +#include + +int main() { + while(1) { + int a, b, c; + scanf("%d %d %d", &a, &b, &c); + + a *= a; + b *= b; + c *= c; + + if(a == 0 && b == 0 && c == 0) { + break; + } + else if(((a + b) == c) || ((a + c) == b) || ((c + b) == a)) { //문제에서 c가 제일 큰 변이라는 보장이 없음 + printf("right\n"); + } + else { + printf("wrong\n"); + } + + } + return 0; +} diff --git a/Soyoung/C_study.c b/Soyoung/C_study.c new file mode 100644 index 0000000..9d12d8a --- /dev/null +++ b/Soyoung/C_study.c @@ -0,0 +1,20 @@ +#include + +int main() { + int T; + scanf("%d", &T); + for(int t=0; t