구조체를 이용한 성적관리 프로그램 소스 해석 좀 부탁드립니다.
콩알녀
#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 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;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;
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2700562 | 함수포인터에서요 (7) | 소심한여자 | 2025-07-06 |
2700530 | 전처리문 질문입니다. (1) | 아놀드 | 2025-07-05 |
2700510 | c언어를 어케하면 잘할수 있을까요.. | 연연두 | 2025-07-05 |
2700484 | 두 개가 차이가 뭔지 알려주세요...(소수 찾는 프로그램) (2) | 날위해 | 2025-07-05 |
2700426 | 인터넷 창 띄우는 질문이요 (1) | 정훈 | 2025-07-04 |
2700400 | 원넓이를 계산이요 ㅜㅜ | 천칭자리 | 2025-07-04 |
2700368 | if에 관해서 질문이요... | Orange | 2025-07-04 |
2700339 | 이거 결과값이 왜이런건지.. (4) | 그댸와나 | 2025-07-04 |
2700313 | 파일 읽어서 저장하는데 빈파일일 경우 문재가 발생하네요.. (2) | 크나 | 2025-07-03 |
2700287 | 구조체 동적할당 연습을 하는데 오류가 뜹니다...(해결) (3) | 아련나래 | 2025-07-03 |
2700264 | 문자와 숫자 동시에 입력??? | 글고운 | 2025-07-03 |
2700236 | txt파일로만 쓰고 읽게 하려면 어떻게 해야 하나요..?? (8) | 미국녀 | 2025-07-03 |
2700211 | 전위 연산자 (2) | 어른처럼 | 2025-07-02 |
2700183 | C에서 파일이름을 받고, 그 파일의 사이즈를 출력해줘야하는데 내용이 출력이 안되네요 ;ㅅ; | 피스케스 | 2025-07-02 |
2700150 | 꼭좀 도와주세요ㅠㅠㅠ | 호습다 | 2025-07-02 |
2700095 | 연산문제...질문... | 오빤테앵겨 | 2025-07-01 |
2700070 | while문 , 3의배수 출력하는 프로그램좀 짜주세욤. | 횃불 | 2025-07-01 |
2700041 | 초보인데요 ㅎ 배열안에 배열을 집어넣을수 있나요?? | 헛장사 | 2025-07-01 |
2700012 | 배열// (1) | 전갈자리 | 2025-07-01 |
2699895 | 무한루프에 빠집니다.!! 해결좀부탁드려요 (10) | 선아 | 2025-06-30 |