성적처리에서 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;
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2654185 | 64bit 환경에서 자료형의 크기가 좀궁그해요(완료) 더궁금한게 생겻어요(추가) (2) | 빈길 | 2024-05-08 |
2654152 | 확장자 exe로 변경 (1) | 한 | 2024-05-08 |
2654128 | c언어 간단하게 자판기만들려는데 ㅜㅜ | 유1혹 | 2024-05-08 |
2654074 | 배열에 들어있는값을 포인터에 옮기고 싶어요.. | 소라 | 2024-05-07 |
2654043 | 이차원 배열에 있는 값들 더하기.. | 선아 | 2024-05-07 |
2654011 | c언어 대문자소문자, 소문자대문자 변형하기, | 샤르 | 2024-05-07 |
2653985 | 실수 자료형 표현범위있잖아요 (1) | 패틱 | 2024-05-06 |
2653957 | 뭐가틀린건가요?.. (2) | 볼1매그녀 | 2024-05-06 |
2653934 | malloc을 이용한 출력 (1) | 하예 | 2024-05-06 |
2653906 | 숫자 야구 게임인데요.. (2) | 상큼한캔디 | 2024-05-06 |
2653883 | 구조체 질문이요.. 연결리스트. (1) | 별 | 2024-05-05 |
2653802 | 배열에 저장된 데이터와 원하는 데이터비교하는것좀.. | 리카 | 2024-05-05 |
2653727 | 고수님들 봐주세요~ (2) | 아담 | 2024-05-04 |
2653702 | C언어 의 단계가 어떻게 되나요???????????????? (3) | 길가온 | 2024-05-04 |
2653645 | 저....while인데..이게무슨뜻인지좀.. | 설희 | 2024-05-03 |
2653613 | 성별변수 | 뿡뿡 | 2024-05-03 |
2653584 | 16진수 변환 관련 질문 드립니다. | 매미꽃 | 2024-05-03 |
2653557 | 한글 완성형과 조합형의 전환 | 해지개 | 2024-05-02 |
2653506 | void형 포인터 이해안가요 ㅠㅠ (2) | 뭘봐요 | 2024-05-02 |
2653482 | 패턴매칭에 대한 질문하나 올립니다 | 미투리 | 2024-05-02 |