수다닷컴

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

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

시내

2023.04.01

#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

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

번호 제 목 글쓴이 날짜
2701453 MFC문제점 해결방안좀알려주세요~~ 나샘 2025-07-14
2701429 자료형에 관한 질문 (5) 펴라 2025-07-14
2701377 훌로트형 변수를, 서식문자 %d로 읽기 vs 인트형 포인터로 참조하기 LetMeGo 2025-07-13
2701291 콘솔에서 종료시킬때 메시지를 안띄우려면 어떻게 해야하나요? (1) 세실 2025-07-12
2701262 씨언어 좀 봐주세요 아담 2025-07-12
2701211 토큰추출 겨루 2025-07-12
2701159 연산자문제 알려주세요 도1도캣 2025-07-11
2701130 중적분문제입니다. 적분구간에 변수가 들어갈순 없나요??ㅡㅜ 풀큰 2025-07-11
2701098 난수에 질문드립니다. 큰뫼 2025-07-11
2701070 또다른 시험문제 질문올립니다 채련 2025-07-10
2701042 뭐가 잘못된건지 잘 모르겠습니다.;; 지은 2025-07-10
2700986 뭐가 잘못된건지좀 봐주세요. 우주 2025-07-10
2700932 도와주세요 ㅠㅠ 모르겟어요 ㅠ 유희 2025-07-09
2700900 반복문 도움요청..!!합니다. (1) 두힘 2025-07-09
2700875 (유효성검사)프로그램 짜는데 질문이 잇습니다. 휑하니 2025-07-09
2700852 링크드 리스트 구현시 malloc 관련 에러 입니다. 삐용삐용 2025-07-08
2700828 7/4 와 7/4.0 의 차이 발랄한그1녀 2025-07-08
2700771 아스키값 질문입니다. (+추가 임베디드 다른것도!) (3) 찰스 2025-07-08
2700746 코드 오류 질문드립니다 차분 2025-07-07
2700721 배열 프로그래밍 입니다. (1) 크나 2025-07-07
<<  이전  1 2 3 4 5 6 7 8 9 10  다음  >>

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