内容发布更新时间 : 2024/12/22 22:14:03星期一 下面是文章的全部内容请认真阅读。
{ int i,j; float h;
float s_var(void); float highest();
void input_stu(void); void aver_stu(void); void aver_cour(void); input_stu(); aver_stu(); aver_cour();
printf(\ NO. cour1 cour2 cour3 cour4 cour5 for(i=0;i {printf(\ for(j=0;j printf(\ printf(\ } printf(\ for (j=0;j printf(\ printf(\ h=highest(); printf(\ NO. - course -\\n\ printf(\ return 0; } void input_stu(void) {int i,j; for (i=0;i {printf(\ for (j=0;j scanf(\ } } void aver_stu(void) {int i,j; float s; for (i=0;i {for (j=0,s=0;j aver\\n\ } } void aver_cour(void) {int i,j; float s; for (j=0;j for (i=0;i float highest() {float high; int i,j; high=score[0][0]; for (i=0;i return(high); } float s_var(void) {int i; float sumx,sumxn; sumx=0.0; sumxn=0.0; for (i=0;i {sumx+=a_stu[i]*a_stu[i]; sumxn+=a_stu[i]; } return(sumx/N-(sumxn/N)*(sumxn/N)); } 7-15 #include int main() {void input(int [],char name[][8]); void sort(int [],char name[][8]); void search(int ,int [],char name[][8]); int num[N],number,flag=1,c; char name[N][8]; input(num,name); sort(num,name); while (flag==1) {printf(\ scanf(\ search(number,num,name); printf(\ getchar(); c=getchar(); if (c=='N'||c=='n') flag=0; } return 0; } void input(int num[],char name[N][8]) {int i; for (i=0;i {printf(\ scanf(\ printf(\ getchar(); gets(name[i]); } } void sort(int num[],char name[N][8]) { int i,j,min,templ; char temp2[8]; for (i=0;i for (j=i;j if (num[min]>num[j]) min=j; templ=num[i]; strcpy(temp2,name[i]); num[i]=num[min]; strcpy (name[i],name[min]); num[min]=templ; strcpy(name[min],temp2); } printf(\ for (i=0;i printf(\ } void search(int n,int num[],char name[N][8]) {int top,bott,mid,loca,sign; top=0; bott=N-1; loca=0; sign=1; if ((n while((sign==1) && (top<=bott)) {mid=(bott+top)/2; if (n==num[mid]) {loca=mid; printf(\ sign=-1; } else if (n if (sign==1 || loca==-1) printf(\ } 8-1 #include { void swap(int *p1,int *p2); int n1,n2,n3; int *p1,*p2,*p3; printf(\ scanf(\ p1=&n1; p2=&n2; p3=&n3; if(n1>n2) swap(p1,p2); if(n1>n3) swap(p1,p3); if(n2>n3) swap(p2,p3);