20250520 baekjoon
This commit is contained in:
parent
397a1d25df
commit
8e64866d8e
15
code_study/Baekjoon/c/10807.c
Normal file
15
code_study/Baekjoon/c/10807.c
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
int main(){
|
||||||
|
int arr[100];
|
||||||
|
int n, v, cnt=0;
|
||||||
|
scanf("%d",&n);
|
||||||
|
for(int i=0; i<n; i++){
|
||||||
|
scanf("%d",&arr[i]);
|
||||||
|
}
|
||||||
|
scanf("%d",&v);
|
||||||
|
for(int i=0; i<n; i++){
|
||||||
|
if(arr[i]==v) cnt++;
|
||||||
|
}
|
||||||
|
printf("%d",cnt);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
18
code_study/Baekjoon/c/10810.c
Normal file
18
code_study/Baekjoon/c/10810.c
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
int main(){
|
||||||
|
int n, m, i, j, k;
|
||||||
|
int arr[100]={0};
|
||||||
|
|
||||||
|
scanf("%d %d",&n, &m);
|
||||||
|
|
||||||
|
while(m--){
|
||||||
|
scanf("%d %d %d",&i,&j,&k);
|
||||||
|
for(int x =i-1;x<j;x++){
|
||||||
|
arr[x] = k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int t=0; t<n; t++){
|
||||||
|
printf("%d ",arr[t]);
|
||||||
|
}
|
||||||
|
}
|
||||||
21
code_study/Baekjoon/c/10811.c
Normal file
21
code_study/Baekjoon/c/10811.c
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
int main(){
|
||||||
|
int arr[100];
|
||||||
|
int m,n,x,i,j,t;
|
||||||
|
scanf("%d %d",&n, &m);
|
||||||
|
|
||||||
|
for(x=0; x<n; x++) arr[x] = x+1;
|
||||||
|
|
||||||
|
while(m--){
|
||||||
|
scanf("%d %d",&i,&j);
|
||||||
|
for(x=0;x<(j-i+1)/2;x++){
|
||||||
|
t = arr[i+x-1];
|
||||||
|
arr[i+x-1] = arr[j-x-1];
|
||||||
|
arr[j-x-1] = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(x=0; x<n; x++) printf("%d ",arr[x]);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
22
code_study/Baekjoon/c/10813.c
Normal file
22
code_study/Baekjoon/c/10813.c
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
int main(){
|
||||||
|
int n, m, x, y, t;
|
||||||
|
scanf("%d %d",&n, &m);
|
||||||
|
|
||||||
|
int arr[100];
|
||||||
|
for(int i=0; i<n; i++) arr[i] = i+1;
|
||||||
|
|
||||||
|
while(m--){
|
||||||
|
scanf("%d %d",&x, &y);
|
||||||
|
t = arr[x-1];
|
||||||
|
arr[x-1] = arr[y-1];
|
||||||
|
arr[y-1] = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int j=0; j<n; j++){
|
||||||
|
printf("%d ",arr[j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
25
code_study/Baekjoon/c/10818.c
Normal file
25
code_study/Baekjoon/c/10818.c
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
int main(){
|
||||||
|
int n;
|
||||||
|
int min, max;
|
||||||
|
|
||||||
|
scanf("%d",&n);
|
||||||
|
int *arr = malloc(sizeof(int)*n);
|
||||||
|
|
||||||
|
for(int i=0; i<n; i++){
|
||||||
|
scanf("%d",&arr[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
min = arr[0];
|
||||||
|
max = min;
|
||||||
|
|
||||||
|
for(int j=1; j<n; j++){
|
||||||
|
if (arr[j]<min) min=arr[j];
|
||||||
|
if (arr[j]>max) max=arr[j];
|
||||||
|
}
|
||||||
|
free(arr);
|
||||||
|
printf("%d %d",min, max);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
13
code_study/Baekjoon/c/10871.c
Normal file
13
code_study/Baekjoon/c/10871.c
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
int main(){
|
||||||
|
int n,x;
|
||||||
|
scanf("%d %d",&n,&x);
|
||||||
|
int arr[10000];
|
||||||
|
for(int i=0; i<n; i++){
|
||||||
|
scanf("%d",&arr[i]);
|
||||||
|
}
|
||||||
|
for(int j=0; j<n; j++){
|
||||||
|
if(arr[j]<x) printf("%d ",arr[j]);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
23
code_study/Baekjoon/c/1546.c
Normal file
23
code_study/Baekjoon/c/1546.c
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
int main(){
|
||||||
|
float arr[1000];
|
||||||
|
float sum=0;
|
||||||
|
int n, i, temp, max=0;
|
||||||
|
|
||||||
|
scanf("%d", &n);
|
||||||
|
|
||||||
|
for(i=0; i<n; i++) {
|
||||||
|
scanf("%d",&temp);
|
||||||
|
if(max<temp) max=temp;
|
||||||
|
arr[i] = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i=0; i<n; i++){
|
||||||
|
arr[i] = arr[i]/max*100;
|
||||||
|
sum += arr[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%f",sum/n);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
13
code_study/Baekjoon/c/2562.c
Normal file
13
code_study/Baekjoon/c/2562.c
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
int main(){
|
||||||
|
int max=0, idx=0, v;
|
||||||
|
for (int i=0; i<9; i++){
|
||||||
|
scanf("%d",&v);
|
||||||
|
if(v>max){
|
||||||
|
max = v;
|
||||||
|
idx = i+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("%d\n%d",max,idx);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
21
code_study/Baekjoon/c/3052.c
Normal file
21
code_study/Baekjoon/c/3052.c
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
int main(){
|
||||||
|
int arr[42] = {0};
|
||||||
|
int n=0, cnt=0, flag=1, i=0;
|
||||||
|
|
||||||
|
for(i=0; i<42; i++) arr[i]=i;
|
||||||
|
|
||||||
|
for(i=0; i<10; i++){
|
||||||
|
scanf("%d",&n);
|
||||||
|
if(n%42==0) flag=0;
|
||||||
|
arr[n%42] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i=flag; i<42; i++){
|
||||||
|
if(arr[i]==0) cnt++;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%d",cnt);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
19
code_study/Baekjoon/c/5597.c
Normal file
19
code_study/Baekjoon/c/5597.c
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
int main(){
|
||||||
|
int arr[30];
|
||||||
|
int n;
|
||||||
|
|
||||||
|
for(int i=0; i<30; i++) arr[i] = i+1;
|
||||||
|
|
||||||
|
for(int j=0; j<28; j++){
|
||||||
|
scanf("%d", &n);
|
||||||
|
arr[n-1] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int k=0; k<30; k++){
|
||||||
|
if(arr[k]!=0) printf("%d\n",arr[k]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user