主题:[讨论]各位大虾。帮个忙,程序纠错。
[code=c]
#include<stdio.h>
struct Student
{
long unsigned id;
double grades ;
};
typedef struct Student student;
void Input (student *pa,int n);
void Output(const student *pa,int n);
void SelectSort(student *pa, int n);
int main()
{
student sa[3];
printf("Enter 3 records:\n");
Input(sa ,3);
printf("After Sort:\n");
SelectSort(sa,3);
Output(sa,3);
return 0;
}
void Input(stdent *pa ,int n);
{
int i;
for(i=0;i<n;i++)
{
printf("id: ");
scanf("%ld",&pa[i].id);
printf("grades: ");
scanf("%lf",&pa[i].grades);
}
}
void SelectSort (student*pa,int n);
int i,j,min;
Student temp;
for(i=0;i<n-1;i++)
{
min=i;
for(j=i;j<n-1;j++)
{
if(pa[j].grades<pa[min].grades)
min=j;
if(min!=i)
{
temp=pa[i];
pa[i]=pa[min];
pa[min]=temp;
}
}
}
}
void Output( const student *pa,int n);
{
int i;
for(i=0;i<n;i++)
printf("%ld:%g\n",(pa+i)->grades);
}
[/code]--------Configuration: doubt - Win32 Debug--------------------
Compiling...
doubt.c
c:\documents and settings\administrator\桌面\doubt.c(24) : error C2143: syntax error : missing ')' before '*'
c:\documents and settings\administrator\桌面\doubt.c(24) : error C2143: syntax error : missing '{' before '*'
c:\documents and settings\administrator\桌面\doubt.c(24) : error C2059: syntax error : 'type'
c:\documents and settings\administrator\桌面\doubt.c(24) : error C2059: syntax error : ')'
c:\documents and settings\administrator\桌面\doubt.c(25) : error C2449: found '{' at file scope (missing function header?)
c:\documents and settings\administrator\桌面\doubt.c(34) : error C2059: syntax error : '}'
c:\documents and settings\administrator\桌面\doubt.c(39) : error C2061: syntax error : identifier 'temp'
c:\documents and settings\administrator\桌面\doubt.c(39) : error C2059: syntax error : ';'
c:\documents and settings\administrator\桌面\doubt.c(40) : error C2059: syntax error : 'for'
c:\documents and settings\administrator\桌面\doubt.c(40) : error C2143: syntax error : missing '{' before '<'
c:\documents and settings\administrator\桌面\doubt.c(40) : error C2059: syntax error : '<'
c:\documents and settings\administrator\桌面\doubt.c(40) : error C2143: syntax error : missing '{' before '++'
c:\documents and settings\administrator\桌面\doubt.c(40) : error C2059: syntax error : '++'
c:\documents and settings\administrator\桌面\doubt.c(40) : error C2059: syntax error : ')'
c:\documents and settings\administrator\桌面\doubt.c(55) : error C2059: syntax error : '}'
c:\documents and settings\administrator\桌面\doubt.c(57) : error C2449: found '{' at file scope (missing function header?)
c:\documents and settings\administrator\桌面\doubt.c(61) : error C2059: syntax error : '}'
执行 cl.exe 时出错.
doubt.obj - 1 error(s), 0 warning(s)
[code=c]
请填写代码
[/code][code=c]
请填写代码
[/code]
是说3个学生的信息,根据成绩排序,
可是报错太多太多,
迷茫。
请指教。
谢谢。
#include<stdio.h>
struct Student
{
long unsigned id;
double grades ;
};
typedef struct Student student;
void Input (student *pa,int n);
void Output(const student *pa,int n);
void SelectSort(student *pa, int n);
int main()
{
student sa[3];
printf("Enter 3 records:\n");
Input(sa ,3);
printf("After Sort:\n");
SelectSort(sa,3);
Output(sa,3);
return 0;
}
void Input(stdent *pa ,int n);
{
int i;
for(i=0;i<n;i++)
{
printf("id: ");
scanf("%ld",&pa[i].id);
printf("grades: ");
scanf("%lf",&pa[i].grades);
}
}
void SelectSort (student*pa,int n);
int i,j,min;
Student temp;
for(i=0;i<n-1;i++)
{
min=i;
for(j=i;j<n-1;j++)
{
if(pa[j].grades<pa[min].grades)
min=j;
if(min!=i)
{
temp=pa[i];
pa[i]=pa[min];
pa[min]=temp;
}
}
}
}
void Output( const student *pa,int n);
{
int i;
for(i=0;i<n;i++)
printf("%ld:%g\n",(pa+i)->grades);
}
[/code]--------Configuration: doubt - Win32 Debug--------------------
Compiling...
doubt.c
c:\documents and settings\administrator\桌面\doubt.c(24) : error C2143: syntax error : missing ')' before '*'
c:\documents and settings\administrator\桌面\doubt.c(24) : error C2143: syntax error : missing '{' before '*'
c:\documents and settings\administrator\桌面\doubt.c(24) : error C2059: syntax error : 'type'
c:\documents and settings\administrator\桌面\doubt.c(24) : error C2059: syntax error : ')'
c:\documents and settings\administrator\桌面\doubt.c(25) : error C2449: found '{' at file scope (missing function header?)
c:\documents and settings\administrator\桌面\doubt.c(34) : error C2059: syntax error : '}'
c:\documents and settings\administrator\桌面\doubt.c(39) : error C2061: syntax error : identifier 'temp'
c:\documents and settings\administrator\桌面\doubt.c(39) : error C2059: syntax error : ';'
c:\documents and settings\administrator\桌面\doubt.c(40) : error C2059: syntax error : 'for'
c:\documents and settings\administrator\桌面\doubt.c(40) : error C2143: syntax error : missing '{' before '<'
c:\documents and settings\administrator\桌面\doubt.c(40) : error C2059: syntax error : '<'
c:\documents and settings\administrator\桌面\doubt.c(40) : error C2143: syntax error : missing '{' before '++'
c:\documents and settings\administrator\桌面\doubt.c(40) : error C2059: syntax error : '++'
c:\documents and settings\administrator\桌面\doubt.c(40) : error C2059: syntax error : ')'
c:\documents and settings\administrator\桌面\doubt.c(55) : error C2059: syntax error : '}'
c:\documents and settings\administrator\桌面\doubt.c(57) : error C2449: found '{' at file scope (missing function header?)
c:\documents and settings\administrator\桌面\doubt.c(61) : error C2059: syntax error : '}'
执行 cl.exe 时出错.
doubt.obj - 1 error(s), 0 warning(s)
[code=c]
请填写代码
[/code][code=c]
请填写代码
[/code]
是说3个学生的信息,根据成绩排序,
可是报错太多太多,
迷茫。
请指教。
谢谢。