C프로그램 소스와 주석
닫기
  • 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
해당 자료는 10페이지 까지만 미리보기를 제공합니다.
10페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

C프로그램 소스와 주석에 대한 보고서 자료입니다.

본문내용

#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

키워드

  • 가격3,000
  • 페이지수42페이지
  • 등록일2006.12.05
  • 저작시기2006.7
  • 파일형식한글(hwp)
  • 자료번호#380475
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니