성적처리에서 10등까지의 학번과 성적을 산출하는 프로그램을 만드는데요ㅜㅜ
에다
질문 제목 :성적처리에서 10등까지의 학번과성적을 산출하는 프로그램을 만드는데요ㅜㅜ질문 요약 :빨간줄 표시된곳부터 막혀요ㅜㅠ 고수님들 도와주세요질문 내용 :
헤더파일
typedef struct student
{
char studentnumber;
float score;
} student;
int comparebyave (const void *e1,const void *e2);
void printstudent(const student* std, int num);
int comparebyave(const void *e1, const void *e2)
{
student *p1 = (student *) e1;
student *p2 = (student *) e2;
float temp = p2 -score - p1 - score ;
if(temp ==0)
return 0;
if (temp0)
return 1;
return -1;
}
=======================
cpp
#include stdio.h
#include stdlib.h
#include string.h
#include toa.h
void printstudent(const student* std, int num)
{
int i;
for(i=0 ; i10 ; i++)
printf(%-10s %5. %f\n,std[i].studentnumber, std[i].score);//문자 숫자 구별
}
int main()
{
int a=0;
int studentnumbers[60];
float score[60];
int i;
printf(this program is to find the top 10 of the class\n);
printf(how many students are there in your class?);
scanf(%d,a);//count수만큼 학생이 있습니다.
for(i=0; ia; i++)
{
printf(write down the codes and averages of students:);//학번과 성적을 입력하시오
scanf(%d %f,studentnumbers[i], score[i]);
}student std[100] =
{
for(i=0 ; ia ; i++)
{
{studentnumbers[i], score[i]}
}
};
qsort(std,10,sizeof(student),comparebyave);
printf(the rank would be \n);
printstudent(std,10);
getchar();
return 0;
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2694012 | 전공 비전공자 개발자 (10) | 말글 | 2025-05-07 |
2693984 | 오버로딩이 무엇인가요? (2) | 헛매질 | 2025-05-07 |
2693956 | PlaySound재생이 안됩니다!(C에 음악넣기) | 지존 | 2025-05-06 |
2693928 | &와 *의 사용에 관한 명확한 이해 | 제나 | 2025-05-06 |
2693903 | 반복문 설명좀요 ㅠㅠ (2) | 란새 | 2025-05-06 |
2693869 | stdio.h 는 왜 쓰는건가요? (1) | 큰꽃들 | 2025-05-06 |
2693842 | 포인터 변수의 주소값끼리 더하는 것에 대해서 질문드립니다. (1) | 진솔 | 2025-05-05 |
2693811 | 소수 출력;;;; | 화이트캣 | 2025-05-05 |
2693788 | 이런 함수는 없나요? (3) | 앤드류 | 2025-05-05 |
2693758 | txt파일 불러와서 행렬로 저장 | 큰애 | 2025-05-05 |
2693727 | scanf 오류 문제!! (2) | 큰나래 | 2025-05-04 |
2693704 | 구조체 주소록 문제인데 도와주세요 (2) | 도1도캣 | 2025-05-04 |
2693676 | 열혈강의 c언어 질문입니다 | 하양이 | 2025-05-04 |
2693647 | 12.620000 을요 12.620 으로 어떻게 표현해요? (2) | 파도 | 2025-05-04 |
2693619 | 타이틀 코드.. | 단순드립 | 2025-05-03 |
2693591 | 컴파일 에러에서 질문드립니다 (3) | 게자리 | 2025-05-03 |
2693463 | 동적할당 이용시 fwrite사용을 어떻게 해야하나요..? (10) | 일본어못해요 | 2025-05-02 |
2693387 | 배열문제입니다 수정오류캡쳐했습니다 (6) | 연하얀 | 2025-05-01 |
2693356 | text 입출력 내림차순 질문입니다 ㅠ | 빛글 | 2025-05-01 |
2693328 | C언어를이용해서 .txt파일 외에 다른 확장자 파일 삭제가 가능한지.. (2) | 대나무 | 2025-05-01 |