📄 链表的冒泡排序t.cpp
字号:
#include "stdio.h"
#define N 2
#define NULL 0
struct student
{
char num[5];
char name[8];
float score1;
float score2;
struct student next;
};
void main()
{
void print(struct student stu[N]);
int i=0,j=0;
for(i=0;i<N;i++)
{
printf("\nplease input the student %d\n",i+1);
printf("NO: ");
scanf("%s",stu[i].num);
printf("Name: ");
scanf("%s",stu[i].name);
for(j=0;j<2;j++)
{
printf("score%d: ",j+1);
scanf("%d",&stu[i].score[j]);
}
printf("\n");
}
print(stu);
getchar();
scanf("%d",&i);
}
void sort(struct student *stu)
{
int i=0,j=0;
struct student temp;
while(stu->next!=NULL)
{
if(stu->num>stu->next.num)
stu->next.next=stu;
stu->next=
}
}
void print(struct student *head)
{
int i=0,j=0;
struct student *temp;
printf("\nNo. Name Math Computer\n");
temp=head;
while(temp->next!=null)
{
printf("%5s%8s",temp->num,temp->name);
printf("%10f%10f",temp->score1,temp->score2);
temp=temp->next;
printf("\n");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -