수다닷컴

  • 해외여행
    • 괌
    • 태국
    • 유럽
    • 일본
    • 필리핀
    • 미국
    • 중국
    • 기타여행
    • 싱가폴
  • 건강
    • 다이어트
    • 당뇨
    • 헬스
    • 건강음식
    • 건강기타
  • 컴퓨터
    • 프로그램 개발일반
    • C언어
    • 비주얼베이직
  • 결혼생활
    • 출산/육아
    • 결혼준비
    • 엄마이야기방
  • 일상생활
    • 면접
    • 취업
    • 진로선택
  • 교육
    • 교육일반
    • 아이교육
    • 토익
    • 해외연수
    • 영어
  • 취미생활
    • 음악
    • 자전거
    • 수영
    • 바이크
    • 축구
  • 기타
    • 강아지
    • 제주도여행
    • 국내여행
    • 기타일상
    • 애플
    • 휴대폰관련
  • 프로그램 개발일반
  • C언어
  • 비주얼베이직

구조체를 이용한 성적관리 프로그램 소스 해석 좀 부탁드립니다.

콩알녀

2023.08.30

#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;
}

신청하기





COMMENT

댓글을 입력해주세요. 비속어와 욕설은 삼가해주세요.

번호 제 목 글쓴이 날짜
2694702 이거 뭐가문제인가요 코드수정좀 (3) 맑은 2025-05-13
2694675 C언어 후위표기를 중위표기로 앨런 2025-05-13
2694646 안녕하세요 파일 합치기 함수! (1) 연블루 2025-05-13
2694618 잘몰라서 설명부탁드립니다. scanf 관련 (3) 파라 2025-05-12
2694590 이 코드가 뭐하는 코드일까요? #2 빵순 2025-05-12
2694559 동적할당으로 배열(2차원열)을 만드는데 있어 그걸 함수화시키는데... (1) 늘솔길 2025-05-12
2694532 네트워크에 관하여... (4) 황소자리 2025-05-12
2694503 프로그램 연산 후 바로 종료되는 현상 (6) Judicious 2025-05-11
2694450 while문질문입니다. (1) 허리품 2025-05-11
2694420 C언어 질문할게요(유니코드,자료형,버퍼,캐스트연산자) 은새 2025-05-11
2694370 내일까진데 함수호출 제발 도와주세요!!!!!!!!!11 들찬 2025-05-10
2694339 putchar()의 괄호 안에 int c=10;로 전에 선언된 c를 넣으면 안되는 이유에서 제가 생각한 것이 그 이유가 되는지 확인하고 싶습니다. (3) 미르 2025-05-10
2694316 이 코드 어디가 잘못되었는지 고수분들 ㅠㅠ (2) 나빛 2025-05-10
2694285 언어 공부하는 과정 좀 추천해주세요! (1) 아빠몬 2025-05-09
2694258 카운터.. 질문입니다. (4) 하늘빛눈망울 2025-05-09
2694229 단순한 질문이요 (8) 여름 2025-05-09
2694202 용돈을 가지고 할 수 있는 일을 여러가지로 출력하는 방법 좀 알려주세요! (2) 미나 2025-05-09
2694145 화면깜빡임을 없애고 싶은데요... (1) 어서와 2025-05-08
2694069 unsigned 질문입니다. 힘차 2025-05-07
2694012 전공 비전공자 개발자 (10) 말글 2025-05-07
<<  이전  1 2 3 4 5 6 7 8 9 10  다음  >>

수다닷컴 | 여러분과 함께하는 수다토크 커뮤니티 수다닷컴에 오신것을 환영합니다.
사업자등록번호 : 117-07-92748 상호 : 진달래여행사 대표자 : 명현재 서울시 강서구 방화동 890번지 푸르지오 107동 306호
copyright 2011 게시글 삭제 및 기타 문의 : clairacademy@naver.com