QAQ一个指针冒泡求解答哪里错了
#include <stdio.h>#include <string.h>
struct date
{
int year;
int month;
int day;
};
struct student
{
int num;
char name[20];
struct date birth;
char gender;
float score;
};
void main()
{
void sort(student *ps,int n);
void printfsort(student s[],int n);
student s[10];
int i;
for(i=0;i<10;i++)
{
scanf("%d %s %d-%d-%d %c %f",&s[i].num,&s[i].name,&s[i].birth.year,&s[i].birth.month,&s[i].birth.day,&s[i].gender,&s[i].score);
}
sort(s,10);
printf("After sort(score):\n");
printfsort(s,10);
}
void sort(student *ps,int n)
{
int i,j;
student t;
student *p=ps;
for(i=0;i<n-1;i++)
{
for(j=0;j<n-1-i;j++)
{
student *p2=p+1;
if(p->score<p2->score)
{
t=*p;
*p=*p2;
*p2=t;
p++;
}
//
}
}
}
void printfsort(student s[],int n)
{
int i;
for(i=0;i<10;i++)
{
printf("%d\t%s\t%d-%d-%d\t%c\t%0.1f\t",s[i].num,s[i].name,s[i].birth.year,s[i].birth.month,s[i].birth.day,s[i].gender,s[i].score);
printf("\n");
}
}