티스토리 뷰
애플리케이션 구현
프로그램 설계
- 프로그램 개발 시 요구사항 분석 후 적절한 자료구조를 선택하는 것이 중요함
- 다양한 데이터 타입을 묶어서 처리할 필요가 있는 경우 적절한 자료구조는 구조체임
헤더파일
#include
#define ST_NUM 20
#define NAME_LENGTH 10
typedef struct sungjuk {
char name[NAME_LENGTH];
int kor , eng ,mat;
double avg;
}SUNGJUK;
int inScore (SUNGJUK* , int);
void outScore (SUNGJUK* , int);
void sortScore (SUNGJUK* , int);
main함수
iut main()
{
int sel, totalScnt=0;
SUNGJUK student[ST_NUM];
while(1){
put("|n원하는 메뉴를 선택하세요");
put("1. 성적입력");
put("2. 성적순출력");
put("0. 종료");
scanf("%d", &sel);
fflush(stdin);
switch(sel);
}
}
입출력함수
#include "scoreHeader.h"
int inScore(SUNGJUK * st, int cnt)
{
char op;
do{
fflush(stdin);
printf("\n이름:");
gets(st[cnt].name;
printf("국어:");
scanf("%d", &st[cnt].kor);
printf("영어:");
scanf("%d", &st[cnt].eng);
printf("수학":");
scanf("%d", &st[cnt].mat);
}
}
코드분석
- 매크로 상수는 프로그램의 가독성을 높이고 유지보수를 편리하게 하는 장점이 있음
- 사용자 정의 헤더파일은 ""를 이용하여 기술함.
'JAVA기반 스마트웹 개발2021 > 프로그래밍 언어활용' 카테고리의 다른 글
디버깅 (0) | 2021.08.07 |
---|---|
프로그래밍 언어별 특성 (0) | 2021.08.07 |
전처리기 (0) | 2021.08.02 |
배열 포인터 처리 (0) | 2021.08.02 |
스토리지 클래스 (0) | 2021.08.02 |
댓글
© 2018 webstoryboy