구조체를 이용한 성적관리 프로그램 소스 해석좀 부탁드립니다.
후력
#includestdio.h
#includestdlib.h
#includestring.h
typedef struct Student{ // 학생 구조체 정의
int id; // 학 번
char name[40]; // 이름
int Comp, Eng, Math; // 컴프 영어 미적분학
int sum; // 합계
float Avg; // 평균 //구조체 멤버
char Credit[9]; // a+,a,b+,b,c+,c,d+,d,f
}
Student;
int main(void){
int choice;
int select;
Student *profile[100];
int i, j;
int count = 0;
char choicename[20];
int choiceid;
int insert;
int rank = 1;
while(1){
printf( 성적 관리 프로그램\n);
printf(1. 입 력\n);
printf(2. 출 력\n);
printf(3. 수 정 밎 삭 제\n);
printf(4. 검 색\n);
printf(5. 프 로 그 램 종 료\n);
printf( );
scanf(%d, &choice);
switch(choice){
case 1:{
profile[count] =(Student*)malloc(sizeof(Student));
printf(학번을 입력하세요 : );
scanf(%d, &profile[count]-id);
printf(이름을 입력하세요 : );
scanf(%s, &profile[count]-name);
fflush(stdin);
printf(컴프 성적을 입력하세요 : );
scanf(%d, &profile[count]-Comp);
printf(영어 성적을 입력하세요 : );
scanf(%d, &profile[count]-Eng);
printf(미적분학 성적을 입력하세요 : );
scanf(%d, &profile[count]-Math);
profile[count]-sum = profile[count]-Comp + profile[count]-Eng + profile[count]-Math;
profile[count]-Avg = (float)profile[count]-sum / 3.0;
if(profile[count]-Avg = 95) strcpy(profile[count]-Credit, A+);
else if(profile[count]-Avg = 90) strcpy(profile[count]-Credit, A);
else if(profile[count]-Avg = 85) strcpy(profile[count]-Credit, B+);
else if(profile[count]-Avg = 80) strcpy(profile[count]-Credit, B);
else if(profile[count]-Avg = 75) strcpy(profile[count]-Credit, C+);
else if(profile[count]-Avg = 70) strcpy(profile[count]-Credit, C);
else if(profile[count]-Avg = 65) strcpy(profile[count]-Credit, D+);
else if(profile[count]-Avg = 60) strcpy(profile[count]-Credit, D);
else strcpy(profile[count]-Credit, F);
count++;
break;
}
case 2:{
if(count == 0){
printf(출력할 값이 없습니다.);
break;
}
else{
printf(번호\t|학번\t|이름\t|컴프\t|영어\t|미적분학\t|합계\t|평균\t|학점\t|석차\t\n);
for(i=0;icount;i++){
rank = 1;
if(profile[i]-id == -1) continue;
else{
printf(%d\t|%d\t|%s\t|%d\t|%d\t|%d\t|%d\t|%.2f\t|%s\t|, i+1, profile[i]-id, profile[i]-name, profile[i]-Comp, profile[i]-Eng, profile[i]-Math, profile[i]-sum, profile[i]-Avg, profile[i]-Credit);
for(j=0;jcount;j++){
if(profile[j]-id == -1) continue;
if(profile[i]-sum profile[j] -sum){
rank++;
}
}
printf(%d\n, rank);
}
}
break;
}
}
case 3:{
printf(수정 할 경우에는 1을 삭제할 경우에는 2를 입력하세요 : );
scanf(%d,&insert);
if(insert == 1){
printf(수정할 학번을 입력하세요 : );
scanf(%d, &insert);
for(i=0;icount;i++){
if(profile[i]-id == insert){
printf(컴프 성적을 입력하세요 : );
scanf(%d, &profile[i]-Comp);
printf(영어 성적을 입력하세요 : );
scanf(%d, &profile[i]-Eng);
printf(미적분학 성적을 입력하세요 : );
scanf(%d, &profile[i]-Math);
profile[i]-sum = profile[i]-Comp + profile[i]-Eng + profile[i]-Math;
profile[i]-Avg = (float)profile[i]-sum / 3.0;
if(profile[i]-Avg = 95) strcpy(profile[i]-Credit, A+);
else if(profile[i]-Avg = 90) strcpy(profile[i]-Credit, A);
else if(profile[i]-Avg = 85) strcpy(profile[i]-Credit, B+);
else if(profile[i]-Avg = 80) strcpy(profile[i]-Credit, B);
else if(profile[i]-Avg = 75) strcpy(profile[i]-Credit, C+);
else if(profile[i]-Avg = 70) strcpy(profile[i]-Credit, C);
else if(profile[i]-Avg = 65) strcpy(profile[i]-Credit, D+);
else if(profile[i]-Avg = 60) strcpy(profile[i]-Credit, D);
else strcpy(profile[i]-Credit, F);
break;
}
}
if(i == count)
printf(%d 학번은 없습니다. 다시 입력하세요 \n, insert);
}
else if(insert == 2){
printf(삭제할 학번을 입력하세요 : );
scanf(%d, &insert);
for(i=0;icount;i++){
if(profile[i]-id == insert){
profile[i]-id = -1;
break;
}
}
}
else
printf(다시 입력하세요);
break;
}
case 4:{
while(1){
printf(이름으로 검색 하실거면 1을 학번으로 검색 하실 경우에는 2를 입력 하세요 : );
scanf(%d, &select);
if(select == 1){
printf(이름을 입력 하세요 : );
scanf(%s, &choicename);
fflush(stdin);
for(i=0 for(i=0;icount;i++){
if((strcmp(profile[i]-name, choicename)) == 0){
printf(학번\t|이름\t|컴프\t|영어\t|미적분학\t|합계\t|평균\t|학점\n);
printf(%d\t|%s\t|%d\t|%d\t|%d\t|%d\t|%.2f\t|%s\t\n, profile[i]-id, profile[i]-name, profile[i]-Comp, profile[i]-Eng, profile[i]-Math, profile[i]-sum, profile[i]-Avg, profile[i]-Credit);
break;
}
}
if(i == count)
printf(찾으시는 %s 님의 성적은 없습니다. , choicename);
break;
}
else if(select == 2){
printf(학번을 입력 하세요 : );
scanf(%d, &choiceid);
for(i=0;icount;i++){
if(profile[i]-id == choiceid){
printf(학번\t|이름\t|컴프\t|영어\t|미적분학\t|합계\t|평균\t|학점\n);
printf(%d\t|%s\t|%d\t|%d\t|%d\t|%d\t|%.2f\t|%s\t\n, profile[i]-id, profile[i]-name, profile[i]-Comp, profile[i]-Eng, profile[i]-Math, profile[i]-sum, profile[i]-Avg, profile[i]-Credit);
break;
}
}
if(i == count)
printf(찾으시는 %d학번의 성적은 없습니다. , choiceid);
break;
}
else
printf(잘못 입력 하셨습니다. 다시 입력 하세요\n);
}
}
break;
case 5:
exit(1);
}
printf(\n\n\n);
}
return 0;
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2692210 | 정보 올림피아드 문제인데.. 풀이 과정이 궁금합니다.(재귀함수) (5) | 물티슈 | 2025-04-20 |
2692144 | C언어와 리눅스에 대한 질문입니다. | 싴흐한세여니 | 2025-04-20 |
2692114 | 컨텍스트 스위칭하는데 걸리는 시간 측정.. | YourWay | 2025-04-19 |
2692086 | 간접참조 연산자, 증감연산자 질문이용! (2) | 블랙캣 | 2025-04-19 |
2692056 | 주석좀 달아주세요. 몇개적엇는데 몇개만달아주세요. (2) | DevilsTears | 2025-04-19 |
2691978 | 진수 쉽게 이해하는법... (3) | 지지않는 | 2025-04-18 |
2691949 | getchar() 한 문자를 입력받는 함수 질문 | 채꽃 | 2025-04-18 |
2691919 | 배열 정렬 및 합치기 질문입니다. | 사과 | 2025-04-18 |
2691845 | c언어왕초보 질문이 있습니다........ | 루나 | 2025-04-17 |
2691815 | void add(int num); 함수... (4) | 살랑살랑 | 2025-04-17 |
2691756 | 명령 프롬프트 스크롤바가 없어요 | 두메꽃 | 2025-04-16 |
2691725 | 자료구조에 관련해서 질문이 있어 글을 올립니다. | 누리알찬 | 2025-04-16 |
2691697 | if 문에서 구조체 배열에 저장되있던 문자열 검사하는 법 ? (2) | 민트맛사탕 | 2025-04-16 |
2691678 | C언어 함수 질문이요~!!! | 연보라 | 2025-04-15 |
2691650 | 반복문 | 돋가이 | 2025-04-15 |
2691618 | 링크드리스트 개념 질문이예요 (3) | 맨마루 | 2025-04-15 |
2691592 | 동적할당 이용 배열선언 질문입니다.ㅠㅠ (3) | 허리달 | 2025-04-15 |
2691542 | /=의 용도를 알려주세요 ㅠㅠ! (2) | 아라 | 2025-04-14 |
2691510 | sizeof 연산자 질문입니다 (2) | 종달 | 2025-04-14 |
2691483 | 파일 오픈시 에러 질문드립니다. (2) | 호습다 | 2025-04-14 |