diff --git a/problems/2108/21900398.c b/problems/2108/21900398.c new file mode 100644 index 0000000..2053f92 --- /dev/null +++ b/problems/2108/21900398.c @@ -0,0 +1,65 @@ +#include +#include +int main() +{ + int n; + scanf("%d", &n); + int x; + char arr[5000]; + for (x = 0; x < n; x++) + { + scanf("%d", &arr[x]); + } + int len=strlen(arr);//±æÀÌ ±¸Çϱâ ã±â + //1. sum±¸ÇÏ°í + int sum = 0; + for (x = 0; x < len; x++) + { + sum += arr[x]; + } + //2. sum/N°ª ±¸Çϱâ + printf("%d\n", sum / n); + //3. arr¸¦ sort + int a, b; + for (a = 0; a < len - 1; a++) + { + for (b = a + 1; b < len; b++) + { + if (arr[a] > arr[b]) + { + int temp; + temp = arr[a]; + arr[a] = arr[b]; + arr[b] = temp; + + } + } + } + //4. arr[N/2+1]Ãâ·Â + printf("%d\n", arr[n / 2 ]); + //5. count¹è¿­¸¸µé°í + int count[200] = { 0 }; + for (x = 0; x < len; x++) + { + count[arr[x]]++; + } + //6. count¹è¿­ÀÌ¿ëÇؼ­ ÃÖºó°ªÃ£±â + int Max = count[0]; + int many; + for (x = 0; x < len; x++) + { + if (count[x] > Max) + { + Max = count[x]; + many = x; + } + + } + printf("%d\n", many); + + + //8. max-minÃâ·Â + printf("%d", arr[len-1] - arr[0]); + + + return 0; diff --git a/problems/2581/21900398.c b/problems/2581/21900398.c new file mode 100644 index 0000000..389bbc2 --- /dev/null +++ b/problems/2581/21900398.c @@ -0,0 +1,50 @@ +#include +#include +int main() +{ + char arr[100] = { 0 }; + int t = 0; + int m, n; + scanf("%d\n%d", &m, &n); + int i; + int a; + int flag = 0; + for (i = m; i <= n; i++) + { + for (a = 2; a < i; a++) + { + if (i%a == 0) + { + flag = 0; + break; + } + else + { + flag = 1; + + } + } + if (flag == 1) + { + arr[t] = i; + t++; + } + } + int len = strlen(arr); + if (len == 0) + { + printf("-1"); + return 0; + } + int sum = 0; + int x; + + for (x = 0; x < len; x++) + { + sum += arr[x]; + } + + printf("%d %d", sum, arr[0]); + return 0; + +}