-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from gksksla/master
- Loading branch information
Showing
2 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include<stdio.h> | ||
#include<string.h> | ||
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include<stdio.h> | ||
#include<string.h> | ||
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; | ||
|
||
} |