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));
NODE* 를 반는 CreateNode다. NewNode라는 를 그 당는 malloc로 공 당고 다.
Malloc로 당 공 당 가 끝나 되 는다. 다른 메모리 공 당 기 때문다.(?????)
Malloc로 당 공 당 가 끝나 되 는다. 다른 메모리 공 당 기 때문다.(?????)
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;
}










