范文无忧网范文学习范文大全

C语言数组排序高手快来

12月19日 编辑 fanwen51.com

[高校教师人事管理系统用C数组和链表实现]要是要报告就留邮箱#include#include#includeusing namespace std; const int N=7; class teacher { public: void set(int i); //录入信息 void add(teacher p); //增加资料...+阅读

#include "stdio.h"

#define N 4

void main()

{

long num[N];

float score[N],sum=0,average;

int a,b,i,j;

printf("please input student number:\n");

for(i=0;i scanf("%ld",&num[i]);

printf("please input students' score:\n");

for(i=0;i scanf("%f",&score[i]);

for(j=0;j for(i=0;i if(score[i] {

b=score[i];score[i]=score[i+1];score[i+1]=b;

a=num[i];num[i]=num[i+1];num[i+1]=a;

}

printf("\nscore from high to low:\n");

printf("number\tscore\n");

for(i=0;i printf("%ld\t%g\n",num[i],score[i]);

for(i=0;i sum=sum+score[i];

average=sum/N;

printf("\nscore higher than average score:\n");

printf("number\tscore\n");

for(i=0;i {

if(score[i]>average)

printf("%ld\t%g\n",num[i],score[i]);

}

}

延伸阅读:

c语言中的数组排序#include #include int numSort(int *a,int count_num) { int i,j,min=-1,temp; for(j=count_num-1;j>0;j--) for(i=j-1;i>=0;i--) if(a[j] > a[i]) { temp=a[i]; a[i]=a[j]...

C语言数组排序#include<stdio.h> void main() { int a[10] = { 10,2,3,4,5,6,9,8,7,1 }; int i,j,t; for(j=0;j<10;j++) for(i=0;i<10-1-j;i++) if(a[i]>a[i+1]) /* 由小到大,由大到小时改...

推荐阅读
图文推荐
栏目列表