yrytrytry.cpp

来自「一个不错的程序学生管理系统, 有各程序的输入.及其各种功能」· C++ 代码 · 共 59 行

CPP
59
字号
#include<stdio.h>

#define N 5
  void creat(struct student stu[]);
  void sort(struct student stu[]);
struct student
{
    char num[5];
  float score;
}stu[N];

void main()
{  
int i;
for(i=0;i<N;i++)
{
printf("请输入第%d个学生信息:学号,成绩\n",i+1);
printf("NO.:");
scanf("%s",stu[i].num);
printf("SCORE:");
scanf("%f",&stu[i].score);

printf("\n");
}
sort(stu);
creat(stu);
}
void sort(struct student a[5])

{
int i,j;
struct student temp;
for(i=0;i<N;i++)
{
for(j=i+1;j<N;j++)
	
	if (a[i].score>a[j].score)
	{  
	
		temp=a[i];
	    a[i]=a[j];
        a[j]=temp;
	}

}
}
void creat(struct student stu[5])
{
	int i;
	printf("NO.\tSCORE\t\n");
for(i=0;i<3;i++)
{
	printf("%s\t%f\t",stu[i].num,stu[i].score);
	

printf("\n");
}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?