
-
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
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42


본문내용
#include //printf 이용을 위한 헤더파일포함
int swap(int *x,int *y);
main()//메인함수시작
{
int x=10, y=20;//변수x,y값 저장
swap(&x,&y);//swap 함수 호출
printf("x=%d,y=%d\n",x,y);//x,y값을 출력
}
int swap(int *x, int *y)
{
int z;//변수 z선언
z=*x;
*x=*y;
*y=z;
return;
}
x=20,y=10
Press any key to continue
77)
#include
main()
{
int score;//변수선언
printf("input your score:");
scanf("%d",&score);//score변수에 입력받은값을 대입
switch(score) //score가
{
case 90 : //90이면 A를 출력하고 switch문 탈출
printf("you grade is A\n");
break;
case 80 : //80이면 B를 출력하고 switch문 탈출
printf("you grade is B\n");
break;
case 70 : //70이면 C를 출력하고 switch문 탈출
printf("you grade is C\n");
break;
default : //아무것도 해당되지 않으면 F를 출력
printf("you grade is F\n");
}
}
input your score:90
you grade is A
Press any key to continue
78)
//tree구현 알고리즘//
#include
#define NULL 0
struct tree {
int value;
struct tree *left; //왼쪽을 가리키는 포인터//
struct tree *right; // 오른쪽을 가리키는 포인터//
};
//중위법으로 표현된 tree//
inorder(struct tree *pp)
{
if (pp->left != NULL) //left child가 null일 때까지 left로 이동//
inorder(pp->left);
printf("%d-",pp->value); //실패했을 때의 value를 출력//
if (pp->right != NULL) //right child가 null일 때까지 right로 이동//
inorder(pp->right); //실패했을 때의 value를 출력//
}
main()
{
struct tree x[7]; //struct tree형 배열 선언//
struct tree *p=x+3; //struct tree형 포인터 p는 root node를 가리킴//
//root노드는 x[3]//
x[0].value=6 ; x[0].left=NULL ; x[0].right=NULL; //leaf node//
x[1].value=9 ; x[1].left=&x[0] ; x[1].right=&x[2]; //x[0]과 x[2]의 parent node//
x[2].value=2 ; x[2].left=NULL ; x[2].right=NULL; //leaf node//
x[3].value=20 ; x[3].left=&x[1] ; x[3].right=&x[5]; //root node//
x[4].value=12 ; x[4].left=NULL ; x[4].right=NULL; //leaf node//
x[5].value=3 ; x[5].left=&x[4] ; x[5].right=&x[6]; //x[4]과 x[6]의 parent node//
x[6].value=8 ; x[6].left=NULL ; x[6].right=NULL; //leaf node//
inorder(p);
}
6-9-2-20-12-3-8-Press any key to continue
79)
#include//printf 이용을 위한 헤더파일포함
#include
union company {//공용체 company 선언
char title[10];//char형 배열선언
int sales;//int형 변수 선언
float total;//float형 변수선언
};
main()//메인함수시작
{
union company com1;//공용체 company 시선언
strcpy(com1.title, "Kndu Corps");
printf("title=%s sales=%d total=%3.2f\n",com1.title,com1.sales,com1.total);
com1.sales = 340;
printf("title=%s sales=%d total=%3.2f\n",com1.title,com1.sales,com1.total);
com1.total = 10.0;
printf("title=%s sales=%d total=%3.2f\n",com1.title,com1.sales,com1.total);
}
title=Kndu Corps sales=1969516107 total=289570481180305410000000000000000.00
title=T sales=340 total=0.00
title= sales=1092616192 total=10.00
Press any key to continue
80)
#include
const int a=20; //전역변수 선언
main()
{
int i; //지역변수선언
i=10; //지역변수 i에 10을 대입
printf("i=%d\n",i); //지역변수 i의 값이 출력됨
printf("a=%d\n",a); //전역변수 a의 값이 출력됨
}
i=10
a=20
Press any key to continue
81)
#include
main()
{
int i=65; //변수 i 선언 후 i값을 65로 준다
while(i<=90) // 반복하라 i값이 90보다 작거나 같을때까지..
{
printf("%c",i); //출력하라 i값을 문자로..
i++; //매 실행후 i값을 1씩 증가시켜라..
}
}
ABCDEFGHIJKLMNOPQRSTUVWXYZPress any key to continue
int swap(int *x,int *y);
main()//메인함수시작
{
int x=10, y=20;//변수x,y값 저장
swap(&x,&y);//swap 함수 호출
printf("x=%d,y=%d\n",x,y);//x,y값을 출력
}
int swap(int *x, int *y)
{
int z;//변수 z선언
z=*x;
*x=*y;
*y=z;
return;
}
x=20,y=10
Press any key to continue
77)
#include
main()
{
int score;//변수선언
printf("input your score:");
scanf("%d",&score);//score변수에 입력받은값을 대입
switch(score) //score가
{
case 90 : //90이면 A를 출력하고 switch문 탈출
printf("you grade is A\n");
break;
case 80 : //80이면 B를 출력하고 switch문 탈출
printf("you grade is B\n");
break;
case 70 : //70이면 C를 출력하고 switch문 탈출
printf("you grade is C\n");
break;
default : //아무것도 해당되지 않으면 F를 출력
printf("you grade is F\n");
}
}
input your score:90
you grade is A
Press any key to continue
78)
//tree구현 알고리즘//
#include
#define NULL 0
struct tree {
int value;
struct tree *left; //왼쪽을 가리키는 포인터//
struct tree *right; // 오른쪽을 가리키는 포인터//
};
//중위법으로 표현된 tree//
inorder(struct tree *pp)
{
if (pp->left != NULL) //left child가 null일 때까지 left로 이동//
inorder(pp->left);
printf("%d-",pp->value); //실패했을 때의 value를 출력//
if (pp->right != NULL) //right child가 null일 때까지 right로 이동//
inorder(pp->right); //실패했을 때의 value를 출력//
}
main()
{
struct tree x[7]; //struct tree형 배열 선언//
struct tree *p=x+3; //struct tree형 포인터 p는 root node를 가리킴//
//root노드는 x[3]//
x[0].value=6 ; x[0].left=NULL ; x[0].right=NULL; //leaf node//
x[1].value=9 ; x[1].left=&x[0] ; x[1].right=&x[2]; //x[0]과 x[2]의 parent node//
x[2].value=2 ; x[2].left=NULL ; x[2].right=NULL; //leaf node//
x[3].value=20 ; x[3].left=&x[1] ; x[3].right=&x[5]; //root node//
x[4].value=12 ; x[4].left=NULL ; x[4].right=NULL; //leaf node//
x[5].value=3 ; x[5].left=&x[4] ; x[5].right=&x[6]; //x[4]과 x[6]의 parent node//
x[6].value=8 ; x[6].left=NULL ; x[6].right=NULL; //leaf node//
inorder(p);
}
6-9-2-20-12-3-8-Press any key to continue
79)
#include
#include
union company {//공용체 company 선언
char title[10];//char형 배열선언
int sales;//int형 변수 선언
float total;//float형 변수선언
};
main()//메인함수시작
{
union company com1;//공용체 company 시선언
strcpy(com1.title, "Kndu Corps");
printf("title=%s sales=%d total=%3.2f\n",com1.title,com1.sales,com1.total);
com1.sales = 340;
printf("title=%s sales=%d total=%3.2f\n",com1.title,com1.sales,com1.total);
com1.total = 10.0;
printf("title=%s sales=%d total=%3.2f\n",com1.title,com1.sales,com1.total);
}
title=Kndu Corps sales=1969516107 total=289570481180305410000000000000000.00
title=T sales=340 total=0.00
title= sales=1092616192 total=10.00
Press any key to continue
80)
#include
const int a=20; //전역변수 선언
main()
{
int i; //지역변수선언
i=10; //지역변수 i에 10을 대입
printf("i=%d\n",i); //지역변수 i의 값이 출력됨
printf("a=%d\n",a); //전역변수 a의 값이 출력됨
}
i=10
a=20
Press any key to continue
81)
#include
main()
{
int i=65; //변수 i 선언 후 i값을 65로 준다
while(i<=90) // 반복하라 i값이 90보다 작거나 같을때까지..
{
printf("%c",i); //출력하라 i값을 문자로..
i++; //매 실행후 i값을 1씩 증가시켜라..
}
}
ABCDEFGHIJKLMNOPQRSTUVWXYZPress any key to continue
추천자료
implication chart를 이용한 등가항 제거 프로그램(C로 작성)
c언어에서 2진수->10진수변환하는 프로그램
전자 공학도를 위한 c 언어 프로그램 4장
전자 공학도를 위한 c언어 6장 프로그램
c언어에서의 응용 프로그램
C언어 1000라인짜리 성적산출프로그램
[소스][C언어][API]갤러그/비행기 게임 소스
C언어로 이용할수 있는_프로그램
동적 메모리 할당 + 파일 입출력을 이용한 행렬 곱 소스코드 (c언어)
c언어 성적계산 프로그램 - C언어 계산 프로그램
성적처리 프로그램(C 언어)
[설계과제] C언어 요리레시피 프로그램 제작과정
2017년 2학기 영유아프로그램개발과평가 중간시험과제물 C형(프로젝트 접근법)
소개글