4 ¶
- 는
{{{ }}}면 됩.
문 ¶
11.번 배 내 바, int* a; int b; int **c; &c,c,*c,&a,a 명, 떤 떤 는 를 말 리보.
-는 는 . 따 &c는 를 미는 c는 a 말. *c a . &a는 a , a는 a b를 리는 면 b 말.12. 떤 동 , 런 는 명 봅.
int* a;
int b=5;int* a;
int** c;
c=&a;
a=&b;
a=&b;
- *c=9;
printf("%d %d",*c,**c);
- : int 료 데 를 리는 a, b 5를 , 를 리는 c를 . a 를 c . b 는 a . 리 c 9 . a c 9를 대 . 따 린 *c,**c를 면 a 9 .
- 본 마 번 데 는 부 데를 리 . F 부 리는 R면 빈 F R 리는 문 F,R 만 빈 를 . 따 문를 는 방 많만 는 배 배 N면 N-1만만 는 방. 면 를 낭 . 만 문 는 .
- c는 char,int,float 많 본 데 배, , 등 데부 데 만들 는데, 면 데 typedef . typedef #define 리 미 는 c 데 만 typedef 리 리는 c러 리. #define보 능.
< : typedef 데 데; >
:
#include <stdio.h>
void main()
{
#include <stdio.h>
void main()
{
typedef char *YOU;
YOU name ="color";
YOU color = "red, blue, yellow, black";
printf("name=%s \n",name);
printf("color=%s \n",color);
}YOU name ="color";
YOU color = "red, blue, yellow, black";
printf("name=%s \n",name);
printf("color=%s \n",color);
:
name =color
color =red, blue, yellow, black
name =color
color =red, blue, yellow, black
:
typedef문 데 char를 데 *YOU를 YOU name 면 는 char *name 낸 .
4.를 student 를 만들, student 배 만들 0~3번 배 AClass 들 보를 , 보.
#include<stdio.h>
typedef문 데 char를 데 *YOU를 YOU name 면 는 char *name 낸 .
내부 char 배 , 번 int .
-.. 러 ..#include<stdio.h>
struct Student
{
{
int age;
char name[];
char name[];
};
for(i=0;i<4;i++){
}
return 0;
}
}
-머는 녁 리
림 ¶
8. 는 램 보.
번 8번 들 문를 됩. 면 른들 물봐
1
3 2
4 5 6
10 9 8 7
11 12 13 14 15
21 20 19 18 17 16
hint) Dp = (int**)malloc(sizeof(int*));
번 8번 들 문를 됩. 면 른들 물봐
1
3 2
4 5 6
10 9 8 7
11 12 13 14 15
21 20 19 18 17 16
#include <stdio.h>
int main()
{
int a[6][6];
int i,j;
int count=1;
for(i=0;i<6;i++)
{
if(i%2!=0)
{
for(j=i;j>=0;j--)
{
a[i][j]=count;
count++;
}
}
else
{
for(j=0;j<=i;j++)
{
a[i][j]=count;
count++;
}
}
}
for(i=0;i<6;i++)
{
for(j=0;j<=i;j++)
{
if(a[i][j]<10)
printf("%d ",a[i][j]);
else
printf("%d ",a[i][j]);
}
printf("\n");
}
return 0;
}
9.2를 3x3 만들, 배 는 램 보.hint) Dp = (int**)malloc(sizeof(int*));
10.3 10번를 . 번는 . 모르면 물봐, 른 람 를 보
//10.LinearSearch를 보. 배 1000 , random를 1부 1000 를 덤 배 , 777 배내 는를 면 됩.
&c : c
c : c (a )
*c : c르는 (b )
&a : a
a : a (b )
c==&a
*c==a==&b
12. 떤 동 , 런 는 명 봅.
int* a;
int b=5;
int** c;
c=&a; // c a
a=&b; // a b
**c=9; // c 방(?) 9를
printf("%d %d",*c,**c); // *c는 a 들 **c는 b 들 .
//10.LinearSearch를 보. 배 1000 , random를 1부 1000 를 덤 배 , 777 배내 는를 면 됩.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void random(int a[]);
int main()
{
int x;
int a[1000];
int i;
srand(time(NULL));
for(i=0;i<1000;i++)
{
x=1+rand()%1000;
a[i]=x;
// printf("%d ",a[i]);
}
// printf("\n");
random(a);
return 0;
}
void random(int a[])
{
int find[1000]={0};
int i;
for(i=0;i<1000;i++)
{
if(a[i]==777)
find[i]=i;
if(find[i]!=0)
printf("777 %d번 \n",find[i]);
}
}
11.번 배 내 바, int* a; int b; int **c; &c,c,*c,&a,a 명, 떤 떤 는 를 말 리보.&c : c
c : c (a )
*c : c르는 (b )
&a : a
a : a (b )
c==&a
*c==a==&b
12. 떤 동 , 런 는 명 봅.
int* a;
int b=5;
int** c;
c=&a; // c a
a=&b; // a b
**c=9; // c 방(?) 9를
printf("%d %d",*c,**c); // *c는 a 들 **c는 b 들 .
Circular Queue 무 보.
- 는 료 부는
typedef struct
{
- 배 루 .
- 루 문 Front Rear index는 동므 Empty Full .
typedef 무 보, 를 보.- 루 문 Front Rear index는 동므 Empty Full .
- 는 료 부는
typedef struct
{
char *name;
int age;
char sex;
}Student;int age;
char sex;
를 student 를 만들, student 배 만들 0~3번 배 AClass 들 보를 , 보.
내부 char 배 , 번 int .
무 말 는 물보, 를 .
내부 char 배 , 번 int .
무 말 는 물보, 를 .
#include <stdio.h>
typedef struct
{
char *name;
int age;
char sex;
}Student;
int main()
{
Student Std[4];
int i;
Std[0].name="문";
Std[0].age=24;
Std[0].sex='F';
Std[1].name="";
Std[1].age=24;
Std[1].sex='F';
Std[2].name="";
Std[2].age=23;
Std[2].sex='F';
Std[3].name="림";
Std[3].age=22;
Std[3].sex='F';
printf("\t\t\n");
for(i=0;i<4;i++)
{
printf("%s\t%d\t%c\n",Std[i].name,Std[i].age,Std[i].sex);
}
return 0;
}
¶
복
1~6. Koistudy.net 106~111번
->!
1~6. Koistudy.net 106~111번
->!
7. Koistudy.net 125, 152번( 들면 만) 3n+1
accept받 번 accept받는데 들 른들 물봐 번 보 ^^
-> 못!
accept받 번 accept받는데 들 른들 물봐 번 보 ^^
-> 못!
8. 는 램 보.
번 8번 들 문를 됩. 면 른들 물봐
번 8번 들 문를 됩. 면 른들 물봐
1
3 2
4 5 6
10 9 8 7
11 12 13 14 15
21 20 19 18 17 16
#include <stdio.h>
int main(){
int i,j;
int arr[6][6]={0,};
int num=0;
for(i=0 ; i<6 ; i++){
if(i%2==0){
for(j=0 ; j<=i ; j++) arr[i][j]=++num;
}else{
for(j=i ; j>=0 ; j--) arr[i][j]=++num;
}
}
for(i=0 ; i<6 ; i++){
for(j=0 ; j<6 ; j++){
if(arr[i][j] != 0) printf("%3d",arr[i][j]);
}
printf("\n");
}
return 0;
}
9. 2를 3x3 만들, 배 는 램 보.
hint) Dp = (int**)malloc(sizeof(int*));
hint) Dp = (int**)malloc(sizeof(int*));
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(){
int **p1;
int **p2;
int i,j;
srand(time(NULL));
p1=(int**)malloc(sizeof(int*)*3);
p2=(int**)malloc(sizeof(int*)*3);
for(i=0 ; i<3 ; i++){
p1[i]=(int*)malloc(sizeof(int*)*3);
p2[i]=(int*)malloc(sizeof(int*)*3);
}
for(i=0 ; i<3 ; i++){
for(j=0 ; j<3 ; j++){
p1[i][j]=1+rand()%9;
p2[i][j]=1+rand()%9;
}
}
for(i=0 ; i<3 ; i++){
for(j=0 ; j<3 ; j++){
printf("%3d",p1[i][j]);
}
printf("\n");
}
printf("\n");
for(i=0 ; i<3 ; i++){
for(j=0 ; j<3 ; j++){
printf("%3d",p2[i][j]);
}
printf("\n");
}
printf("\n");
for(i=0 ; i<3 ; i++){
for(j=0 ; j<3 ; j++){
p1[i][j]+=p2[i][j];
printf("%3d",p1[i][j]);
}
printf("\n");
}
return 0;
}
10. 3 10번를 . 번는 . 모르면 물봐, 른 람 를 보
LinearSearch를 보. 배 1000 , random를 1부 1000 를 덤 배 , 777 배내 는를 면 됩. 램 마 ?
(rand()%1000 면 1 1000 .)
LinearSearch를 보. 배 1000 , random를 1부 1000 를 덤 배 , 777 배내 는를 면 됩. 램 마 ?
(rand()%1000 면 1 1000 .)
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(){
int arr[1000];
int i;
int count=0;
srand(time(NULL));
for(i=0 ; i<1000 ; i++){
arr[i]=rand()%1000;
}
for(i=0 ; i<1000 ; i++){
if(arr[i]==777){
printf("%d번 777 \n",i+1);
count++;
}
}
printf("%d \n",count);
if(count == 0){
printf("777\n");
}
return 0;
}
11. 번 배 내 바, int* a; int b; int **c; &c,c,*c,&a,a 명, 떤 떤 는 를 말 리보.
int* a;
int b=10;
int** c;
a=&b;
c=&a;
printf("%d\n",a); //b
printf("%d\n",&a); //a
printf("%d\n",*a); //b
printf("%d\n",b); //b
printf("%d\n",&b); //b
printf("%d\n",c); //a
printf("%d\n",&c); //c
printf("%d\n",*c); //b
12. 떤 동 , 런 는 명 봅.
int* a;
int b=5;
int** c;
c=&a;
a=&b;
**c=9;
printf("%d %d",*c,**c);
b 9 변!
1. LinkedList node를 는 방 보, 런 만 보.
2. Circular Queue 무 보.
란 배(arrangement) 며 를 는 배 놓 를 말.
를 , 내는 .
료를 는 덱 는 , 낼는 내는 덱 는 .
났는 는 를 번 료를 는 . 덱 는 맨 르 돌 면 .
란 배(arrangement) 며 를 는 배 놓 를 말.
를 , 내는 .
료를 는 덱 는 , 낼는 내는 덱 는 .
났는 는 를 번 료를 는 . 덱 는 맨 르 돌 면 .
3. typedef 무 보, 를 보.
typedef 명문 는 료 는 끔 는 명문
<typedef >
typedef <료> <명>;
typedef 명문 는 료 는 끔 는 명문
<typedef >
typedef <료> <명>;
<typedef >
typedef int AA;
AA num=500;
typedef int AA;
AA num=500;
4. 를 student 를 만들, student 배 만들 0~3번 배 AClass 들 보를 , 보.
내부 char 배 , 번 int .
무 말 는 물보, 를 .
내부 char 배 , 번 int .
무 말 는 물보, 를 .
#include <stdio.h>
struct student{
char name[20];
int num;
int age;
};
int main(){
int i;
struct student aclass[3]={{"문",201001,24},
{"",201002,23},
{"림",201003,22}};
for(i=0 ; i<3 ; i++){
printf("%s %d %d\n",aclass[i].name,aclass[i].num,aclass[i].age);
}
return 0;
}
¶
1~6 :D
10.3 10번를 . 번는 . 모르면 물봐, 른 람 를 보
10.3 10번를 . 번는 . 모르면 물봐, 른 람 를 보
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main(void){
int i,ran,arr[1000]={0};
srand(time(NULL));
for(i=0;i<1000;i++){
ran = 1+rand()%1000;
}
if(arr[i]==777){
printf("777I arr[%d] ",i);
}
else
printf("777I .");
return 0;
}
12. 떤 동 , 런 는 명 봅.
int* a;
int b=5;
int** c;
int* a;
int b=5;
int** c;
c=&a;
a=&b;
a=&b;
- *c=9;
printf("%d %d",*c,**c);
1.LinkedList node를 는 방 보, 런 만 보.
NODE*CreateNode(char name [])
{
NODE*NewNode = (NODE*)malloc(sizeof(NODE));
NODE*CreateNode(char name [])
{
NODE*NewNode = (NODE*)malloc(sizeof(NODE));
2. Circular Queue 무 보.
를 는 방 마 배 는 방. 러 배 배 는 데 면 느 overflow 됨 데 배 를 면, 데는 0번 배 들 . 러 보 (circular queue)
를 는 방 마 배 는 방. 러 배 배 는 데 면 느 overflow 됨 데 배 를 면, 데는 0번 배 들 . 러 보 (circular queue)
3. typedef 무 보, 를 보.
1) 료 램 내부 른 는
Typedef _료_릉 _료_;
) typedef unsigned char uchar;
2)더 typedef
Typedef는 는 더 모
//typedef를 면 료 료럼 .
1) 료 램 내부 른 는
Typedef _료_릉 _료_;
) typedef unsigned char uchar;
2)더 typedef
Typedef는 는 더 모
//typedef를 면 료 료럼 .
#include<stdio.h>
typedef int Num;
int main(){
Num a=10;
int b=20;
printf("sum = %d\n",a+b);
return 0;
}
typedef 면 int char 등 료 는 명 바 능.
먼 typedef 변 . 는 int NUM 명 바 .
먼 typedef 변 . 는 int NUM 명 바 .
리 보 료 int 럼 면 . NUM 변 , int를 변 보면 .
4. 를 student 를 만들, student 배 만들 0~3번 배 AClass 들 보를 , 보.
o 내부 char 배 , 번 int .
o 무 말 는 물보, 를 .
o 내부 char 배 , 번 int .
o 무 말 는 물보, 를 .
#include<stdio.h>
#include<string.h>
int main(void){
struct student{
char name[10];
int age;
};
struct student s[4];
int i;
strcpy(s[0].name,"");
s[0].age = 23;
strcpy(s[1].name,"");
s[1].age = 24;
strcpy(s[2].name,"문");
s[2].age = 24;
strcpy(s[3].name,"림");
s[3].age = 22;
for(i=0;i<4;i++){
printf(" : %s\n",s[i].name);
printf(" : %d\n",s[i].age);
}
return 0;
}










