문 ¶
#.20105801 문
1~5.www.koistudy.net 디 100번~104번 Accept받(등 면 문 를 보내)
-#include<stdio.h>
int main()
{
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d",a+b);
return 0;scanf("%d %d",&a,&b);
printf("%d",a+b);
}
-#include<stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d %d",a/b,a%b);
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d %d",a/b,a%b);
return 0;
}
-#include<stdio.h>
int main()
{
double a,b;
scanf("%lf %lf",&a,&b);
printf("%g ",a*b/2);
{
double a,b;
scanf("%lf %lf",&a,&b);
printf("%g ",a*b/2);
return 0;
}
-#include<stdio.h>
-#include<stdio.h>
int main()
{
float r,c;
{
float r,c;
scanf("%f ",&r);
c=(float)r/2;
printf("%.2f ",c*c*3.14);
c=(float)r/2;
printf("%.2f ",c*c*3.14);
return 0;
}
-#include<stdio.h>
int main()
{
float n1,n2,n3;
{
float n1,n2,n3;
scanf("%f %f %f",&n1,&n2,&n3);
printf("%.3f ",(float)(n1+n2+n3)/3);
printf("%.3f ",(float)(n1+n2+n3)/3);
return 0;
}
6.를 swap 보(대부 . 따 보 를 보)
-#include<stdio.h>
void swap(int *a,int *b);
int main()
{
int main()
{
char x='A',y='B';
printf("x= %c y=%c\n",x,y);swap(&x,&y);
printf("x=%c ,y=%c\n",x,y);
return 0;
printf("x=%c ,y=%c\n",x,y);
return 0;
}
void swap(int *a,int *b)
{
void swap(int *a,int *b)
{
int temp;
temp=*a;
*a=*b;temp=*a;
*b=temp;
}
7.2 배(4x4) 는 램 .
2X2 봤
#include<stdio.h>
printf(" \n");
for(j=0;j<2;j++){
}
for(p=0;b<2;p++){
if(j==0 && p==0){
}else if(j==0&& p==1){
}else if(j==1&&p==0){
}else{
}
cjp=q*w+e*r;
printf("%d",cjp);
}
printf("\n");if(j==0 && p==0){
}else if(j==0&& p==1){
}else if(j==1&&p==0){
}else{
}
cjp=q*w+e*r;
printf("%d",cjp);
}
}
return 0;
}
}
8. 는 램 보.
1 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
21 22 23 24 25
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
21 22 23 24 25
#include<stdio.h>
int main()
{
int a[]5={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};
int c55;
int j,p;
int main()
{
int a[]5={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};
int c55;
int j,p;
for(j=0;j<5;j++){
for(p=0;p<5;p++){
for(p=0;p<5;p++){
}
printf("\n");
j++;
}
printf("\n");
j++;
}
return 0;
}
}
9.를 를 보.
#include<stdio.h>
int main()
{
int main()
{
int num=2;
int *a;
a=#
printf("%d\n",*a);
return 0;
}int *a;
a=#
printf("%d\n",*a);
return 0;
//'0' .
10.LinearSearch를 보. 배 1000 , random를 1부 1000 를 덤 배 , 777 배내 는를 면 됩. 램 마 ?
(rand()%1000 면 1 1000 .)
-linear search란 리 부 는 말.
를 부
#include<stdio..h>
int Lsearch(int ar[], int len, int targer)
{
int i;
for(i=0;i
int Lsearch(int ar[], int len, int targer)
{
int i;
for(i=0;i
return -1;
}
int main(){
int arr[]={3,5,2,4,9};
int idx;
idx=Lsearch(arr,sizeof(arr)/sizeof(int),4);
int idx;
idx=Lsearch(arr,sizeof(arr)/sizeof(int),4);
if(idx== -1)
printf("search fail\n");
else
printf("%d\n",idx);
idx = Lsearch(arr,sizeof(arr)/sizeof(int),7);
printf("search fail\n");
else
printf("%d\n",idx);
idx = Lsearch(arr,sizeof(arr)/sizeof(int),7);
if(idx ==-1)
printf("search fail\n");
else
printf("%d\n",idx);
return 0;
printf("search fail\n");
else
printf("%d\n",idx);
return 0;
}
11.Sort를 보. 11번 방 를 덤 , , 면 됩.
- u.u
- u.u
12.번 배 내 바, int* a; int b; &a,a,*a,&b,b 명, 떤 떤 는 를 말 리보.( 를 보 보는 방 .)
- *a b를 리는 면, &a는 a , a는 메모리 는 (, b - ), &b는 b , b는 메모리 는 ( ),a=&b . b 낸.*a=b b .
#include<stdio.h>
struct Student
{
{
int id;
int age;
char *name;
int age;
char *name;
};
int main()
{
struct Student stu;
{
struct Student stu;
stu.id =1001;
stu.age=10;
stu.name ="kim so ri";
stu.age=10;
stu.name ="kim so ri";
printf("id : %d\n",stu.id);
printf("age : %d\n",stu.age);
printf("name : %s\n",stu.name);
printf("age : %d\n",stu.age);
printf("name : %s\n",stu.name);
return 0;
}
}
2.동 무 보, 동 는 방 보.
-동 malloc 대.....
molloc 는 리 는 료를 메모리 돌 는 .
는 , 리 메모리 ..
molloc 는 리 는 료를 메모리 돌 는 .
는 , 리 메모리 ..
는 방 =
변 = ( 료 )malloc(는 료);
변 = ( 료 )malloc(는 료);
ex..
arr = (int *)malloc(sizeof(int)*nSize); // malloc nSize만 int 배
malloc 는 free 메모리 . 면 메모리 남 .
3. 무 보, 를 2 배 만들보.
- 를 리는 를 .
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
void main()
{
{
int **ptr;
int i,j,k=1;
//int ptr22;
ptr = (int **)malloc(2*sizeof(int *));
for(i=0;i<2;i++)
for(i=0;i<2;i++)
{
}
}int i,j,k=1;
//int ptr22;
ptr = (int **)malloc(2*sizeof(int *));
for(i=0;i<2;i++)
ptri = (int *)malloc(2*sizeof(int));
for(i=0;i<2;i++)
{
}
//
4., 무 명, 를 를 만들보.
-란 방 료, 는 방 들 맨 먼 낼 는 방.
int sp=0;
int push(int);
int pop(int *);
int push(int);
int pop(int *);
int main(){
int n=0;
push(10);
push(20);
push(30);
if (push(40) == -1)
{
push(10);
push(20);
push(30);
if (push(40) == -1)
{
printf("Stack Overflow\n");
}
pop(&n);
printf("pop : %d\n",n);
pop(&n);
printf("pop : %d\n",n);
pop(&n);
printf("pop : %d\n",n);
printf("pop : %d\n",n);
pop(&n);
printf("pop : %d\n",n);
printf("pop : %d\n",n);
if(pop(&n) == -1)
{
printf("Stack Underflow\n");
{
printf("Stack Underflow\n");
}
return 0;
}
return 0;
}
}else
{
{
return -1; // overflow
}}
}else
{
return -1; // . underflow
{
return -1; // . underflow
}
}
}
// pop 데를 마막 들 30부 .
-
#include<stdio.h>
#include<conio.h>
#define MAX 5
#include<stdio.h>
#include<conio.h>
#define MAX 5
void Delete()
{
{
if(rear < 0 )
--rear;
}printf("더 ");
else --rear;
void main()
{
{
int insert_num;
int i,j;
for(i=0; i<5; i++)
{
for(j=0; j
for(j = front ; j < 5; j++){ //엔터를 한번씩 누르면 값이 차례대로 빠짐
}
}int i,j;
for(i=0; i<5; i++)
{
printf("를 ");
scanf("%d", &insert_num);
insert(insert_num);
}scanf("%d", &insert_num);
insert(insert_num);
for(j=0; j
printf("%d " ,queuej); printf("\n");
}for(j = front ; j < 5; j++){ //엔터를 한번씩 누르면 값이 차례대로 빠짐
}
¶
1~5.www.koistudy.net 디 100번~104번 Accept받(등 면 문 를 보내)
6.를 swap 보(대부 . 따 보 를 보)
-06.c
-06.c
7.2 배(4x4) 는 램 .
-07.c
-07.c
8. 는 램 보.
1 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
21 22 23 24 25
-배 는 면 for문 몇 를 는 ,
1 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
21 22 23 24 25
-배 는 면 for문 몇 를 는 ,
9.를 를 보.
-09.c
-09.c
10.LinearSearch를 보. 배 1000 , random를 1부 1000 를 덤 배 , 777 배내 는를 면 됩. 램 마 ?
(rand()%1000 면 1 1000 .)
-10.c
(rand()%1000 면 1 1000 .)
-10.c
11.Sort를 보. 11번 방 를 덤 , , 면 됩.
-11.c
-11.c
12.번 배 내 바, int* a; int b; &a,a,*a,&b,b 명, 떤 떤 는 를 말 리보.( 를 보 보는 방 .)
란 변를 룹 료 는 .
a_01.c
int* a;
int b=10;
a=&b;
printf("%d\n",&a); // 변 a
printf("%d\n",a); //a 리 는
printf("%d\n",&b); //b
printf("%d\n",b); //b 들는
1. 무 보, 를 만들보.int b=10;
a=&b;
printf("%d\n",&a); // 변 a
printf("%d\n",a); //a 리 는
printf("%d\n",&b); //b
printf("%d\n",b); //b 들는
란 변를 룹 료 는 .
a_01.c
2.동 무 보, 동 는 방 보.
’ 메모리를 는 동 .
램 는 동 는 메모리 를 문.
-a_02.c
-> 됨.
’ 메모리를 는 동 .
램 는 동 는 메모리 를 문.
-a_02.c
-> 됨.
3. 무 보, 를 2 배 만들보.
는 는 .
a_03.c
는 는 .
a_03.c
4., 무 명, 를 를 만들보.
– 데 / 만 는 료 . 들 데 먼 .
– 먼 데 먼 는 FIFO. 대는 념 료.
->(는 떻 만들 모르!.)
– 데 / 만 는 료 . 들 데 먼 .
– 먼 데 먼 는 FIFO. 대는 념 료.
->(는 떻 만들 모르!.)
¶
1 100)
#include<stdio.h>
int main(){
#include<stdio.h>
int main(){
int a,b;
scanf("%d",&a);
scanf("%d",&b);
printf("%d",a+b);
return 0;
}scanf("%d",&a);
scanf("%d",&b);
printf("%d",a+b);
return 0;
2 101)
#include <stdio.h>
#include <stdio.h>
int main()
{
{
int a,b,c,d;
scanf("%d %d",&a,&b);
c=a/b;
d=a%b;
printf("%d %d",c,d);
return 0;
}scanf("%d %d",&a,&b);
c=a/b;
d=a%b;
printf("%d %d",c,d);
return 0;
3 102)
#include <stdio.h>
#include <stdio.h>
int main()
{
{
int u,h;
double s;
scanf("%d %d", &u,&h);
s = (u*h)/2.0;
return 0;
}double s;
scanf("%d %d", &u,&h);
s = (u*h)/2.0;
printf("%g",s);
return 0;
4 103)
#include <stdio.h>
#include <stdio.h>
int main()
{
{
int R;
double s,r ;
scanf("%d", &R);
r=R/2.0;
s = 3.14*r*r;
return 0;
}double s,r ;
scanf("%d", &R);
r=R/2.0;
s = 3.14*r*r;
printf("%.2lf",s);
return 0;
5 104)
#include <stdio.h>
#include <stdio.h>
int main()
{
{
int a,b,c;
double ave ;
scanf("%d %d %d", &a, &b, &c);
return 0;
}double ave ;
scanf("%d %d %d", &a, &b, &c);
ave = (float)(a + b + c) / 3.0;
printf("%.3lf",ave); return 0;
6 105)
#include<stdio.h>
int main(){
#include<stdio.h>
int main(){
double a,b,c,d;
scanf("%lf",&a);
scanf("%lf",&b);
scanf("%lf",&c);
d=-(b/a);
printf("%g",d);
return 0;
}scanf("%lf",&a);
scanf("%lf",&b);
scanf("%lf",&c);
d=-(b/a);
printf("%g",d);
return 0;
7.를 swap 보(대부 . 따 보 를 보)
#include <stdio.h>
void point(int *pval1 , int *pval2)
{
{
int temp;
temp = *pval1;
temp = *pval1;
- pval1=*pval2;
- pval2= temp;
void main()
{
{
int val1;
int val2;
val1=10;
val2=20;
printf("%d %d \n" , val1, val2);
point(&val1, &val2);
printf("%d %d \n" , val1, val2);
} int val2;
val2=20;
printf("%d %d \n" , val1, val2);
point(&val1, &val2);
printf("%d %d \n" , val1, val2);
#include <stdio.h>
int main()
{
int a44,b44,c44,d44={0},i,j,k,l;
printf("배öe¯¡© a O¤A : ");
for(i=0; i<4; i++) //a배öe열¯¡© 입O력¤A
{
}
printf("배öe¯¡© b O¤A : ");
for(i=0; i<4; i++) //b배öe열¯¡© 입O력¤A
{
}
for(i=0; i<4; i++)
{
for(i=0; i<4; i++)
{
}
return 0;
}printf("배öe¯¡© a O¤A : ");
for(i=0; i<4; i++) //a배öe열¯¡© 입O력¤A
{
}
printf("배öe¯¡© b O¤A : ");
for(i=0; i<4; i++) //b배öe열¯¡© 입O력¤A
{
}
for(i=0; i<4; i++)
{
for(j=0; j<4; j++)
{
}
}{
for(k=0; k<4; k++)
{
{ {
for(k=0; k<4; l++)
}
}
}for(i=0; i<4; i++)
{
}
return 0;
9. 는 램 보.
1 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
21 22 23 24 25
1 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
21 22 23 24 25
#include <stdio.h>
int main()
{
int main()
{
return 0;
}#include<stdio.h>
int main(){
char ch;
char *p;
char *q;
ch = 'A';
p = &ch;
q = p;
char *p;
char *q;
ch = 'A';
p = &ch;
q = p;
- p = 'Z';
printf("chÆ¢® Æ¢®oÆi O는¥A ƨ£ : ch=> %c\n",ch);
11.LinearSearch를 보. 배 1000 , random를 1부 1000 를 덤 배 , 777 배내 는를 면 됩. 램 마 ?
(rand()%1000 면 1 1000 .)
12.Sort를 보. 11번 방 를 덤 , , 면 됩.
13.번 배 내 바, int* a; int b; &a,a,*a,&b,b 명, 떤 떤 는 를 말 리보.( 를 보 보는 방 .)
&a : a
*a : a 르는 , a 들는
&b : b
*b : b 르는 , b 들는
&a : a
*a : a 르는 , a 들는
&b : b
*b : b 르는 , b 들는
*a = b
*b = a
1.4.1.2 ¶
1. 무 보, 를 만들보.
: 른 데를 러 료 변들
#include<stdio.h>
int main(){
printf("I¬¡× : %s\n",s.name);
printf("ø¨£I : %d\n",s.age);
*b = a
1. 무 보, 를 만들보.
: 른 데를 러 료 변들
#include<stdio.h>
int main(){
printf("I¬¡× : %s\n",s.name);
printf("ø¨£I : %d\n",s.age);
return 0;
}
2.동 무 보, 동 는 방 보.
동 는 : 메모리를
동 번 는 malloc, 를 는 "stdlib.h"더
변 = ( 료 )malloc(는 료);
}
2.동 무 보, 동 는 방 보.
동 는 : 메모리를
동 번 는 malloc, 를 는 "stdlib.h"더
변 = ( 료 )malloc(는 료);
3. 무 보, 를 2 배 만들보.
: 변를 르는
: 변 는 를 른 롤 (바 ) !
: 료를 러를 는 먼 는
(Queue) : 램 보면 료 목 를 . 뒤(rear) 루 는 (front) 루는 료 를 . 메모리 는 방 .
: 변를 르는
: 변 는 를 른 롤 (바 ) !
(데를 는 를 )
방Int **p;
4., 무 명, 를 를 만들보.: 료를 러를 는 먼 는
(Queue) : 램 보면 료 목 를 . 뒤(rear) 루 는 (front) 루는 료 를 . 메모리 는 방 .
림 ¶
12.번 배 내 바, int* a; int b; &a,a,*a,&b,b 명, 떤 떤 는 를 말 리보.( 를 보 보는 방 .)
a : a 들는
&a : a
*a : a 르는 변
&b : b
b : b 들는
a : a 들는
&a : a
*a : a 르는 변
&b : b
b : b 들는
1.4.1.2
1. 무 보, 를 만들보.
- 른 데를 묶 는 데
struct Student
{
int id;
int age;
char* name;
};
2.동 무 보, 동 는 방 보.
- 만 메모리를 동 리 는 .
int* pTmp=malloc(100);
int* pTmp=(int*)malloc(100);
3. 무 보, 를 2 배 만들보.
- 를 르는
- 른 데를 묶 는 데
struct Student
{
int id;
int age;
char* name;
};
2.동 무 보, 동 는 방 보.
- 만 메모리를 동 리 는 .
int* pTmp=malloc(100);
int* pTmp=(int*)malloc(100);
3. 무 보, 를 2 배 만들보.
- 를 르는
4., 무 명, 를 를 만들보.
: LIFO() 료를 먼 는 료
: FIFO() 먼 료 먼 는 료
: LIFO() 료를 먼 는 료
: FIFO() 먼 료 먼 는 료