성적처리 소스 함들었는데.,grade는 어떻게 ㅠㅠ
초코맛사탕
질문 제목 : 도와주세요 ㅠㅠ
질문 내용 :
성적처리 관련 과제 중입니다. 어떻게든 꾸역꾸역 끼워 맞춰서 여기까지 왔는데... A B C D F 학점 주는 것을 못하겠네요... 여기서 어떤식으로 넣어야 하는 건가요???? 도움을 주세요 ㅠㅠ#include stdio.h
#include string.h // 문자열 관련 표준함수 정의. strcmp() 등void InputData(struct student* st, int index);
void ShowData(struct student* st, int index);
void SetRank(struct student* st, int index);#define MAX_NAME 100struct score
{
int middle;
int final;
int report;
int present;
int total;
double avg;
int rank;
int grade;
};struct student{
char name[MAX_NAME]; // 이름
struct score scores; // score 구조체 변수
};int main(void)
{
struct student st[100];
int index=0; printf(이름과 성적을 입력 하시오.!! \n);
for(index=0 ; index2 ; index++)
{
InputData(st, index);
}
SetRank(st, index);
ShowData(st, index); retu; return 0;
}void InputData(struct student* st, int index)
{
printf(이름 : ); scanf(%s, st[index].name);
printf(Middle : ); scanf(%d, &st[index].scores.middle);
printf(Final : ); scanf(%d, &st[index].scores.final);
printf(Report : ); scanf(%d, &st[index].scores.report);
printf(Present : ); scanf(%d, &st[index].scores.present);
;
st[index].scores.total=(st[index].scores.middle+st[index].scores.final+st[index].scores.report+st[index].scores.present);
st[index].scores.avg=(st[index].scores.middle+st[index].scores.final+st[index].scores.report+st[index].scores.present)/4.0;
st[index].scores.rank=1;
}void ShowData(struct student* st, int index)
{
int i;
printf(NAME\tMiddle\Final\tReport\tPresent\tTotal\tAverage\tRank\tGrade\n);
for(i=0 ; iindex ; ++i)
{
printf(%s\t %d\t %d\t %d\t %d\t %d\t %g\t %d\t %d\n, st[i].name, st[i].scores.middle
, st[i].scores.final, st[i].scores.report, st[i].scores.present, st[i].scores.total, st[i].scores.avg, st[i].scores.rank,st[i].scores.grade);
}
}void SetRank(struct student* st, int index)
{
{
int i, j; for(i=0 ; iindex ; ++i)
st[i].scores.rank=1; for(i=0 ; iindex-1 ; ++i)
{
for(j=i+1 ; jindex ; ++j)
{
if(st[i].scores.avgst[j].scores.avg)
st[i].scores.rank++;
else if(st[i].scores.avgst[j].scores.avg)
st[j].scores.rank++;
}
}
}
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
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 |
2699842 | 질문을 너무 많이 하네여.....죄송.... (2) | 해님꽃 | 2025-06-29 |
2699816 | 오류 질문입니다.. (1) | 해비치 | 2025-06-29 |
2699763 | 질문입니다 ! 꼭 좀 도와주세요ㅠㅠ (2) | 미라 | 2025-06-28 |