2道数据结构题1设有n个学生,
下面程序运行成功:
#include "stdio。h"
#include "malloc。h"
#include "string。h"
#define N 3 /*定义班级人数*/
struct Student /*学生信息结构体*/
{
char *number;
char *name;
float score;
}Stu[N];
boble(struct Student *a) /*冒泡排序算法*/
{
int i,j;
struct Student t;
for(j=1;ja[i+1]。 score) /*比较,如果当前数大于后一个数,就交换位置,这样每循环一次就有一个最大的数排...全部
下面程序运行成功:
#include "stdio。h"
#include "malloc。h"
#include "string。h"
#define N 3 /*定义班级人数*/
struct Student /*学生信息结构体*/
{
char *number;
char *name;
float score;
}Stu[N];
boble(struct Student *a) /*冒泡排序算法*/
{
int i,j;
struct Student t;
for(j=1;ja[i+1]。
score) /*比较,如果当前数大于后一个数,就交换位置,这样每循环一次就有一个最大的数排到最后*/
{
mber=a[i]。number;
a[i]。number=a[i+1]。number;
a[i+1]。
number= mber;
=a[i]。name;
a[i]。name=a[i+1]。name;
a[i+1]。name= ;
ore=a[i]。score;
a[i]。score=a[i+1]。
score;
a[i+1]。score= ore;
}
}
main()
{
int i,j;
float sc;
printf("input %d numbers like \"number name score\":\n",N); /*以学号 姓名 成绩顺序输入学生信息*/
for(i=0;i number=(char *)malloc(20);
Stu[i]。name=(char *)malloc(20);
scanf("%s %s %f",Stu[i]。number,Stu[i]。
name,&sc);
Stu[i]。score=sc;
}
boble(&Stu);/*调用冒泡函数*/
printf("\n");
printf("the sorted numbers :\n");
for(i=0;i 2f\n",Stu[i]。number,Stu[i]。name,Stu[i]。score);
}
⑴。 所涉及的信息有:终点站信息(终点站名、车次号、乘车日期、乘客定额、余票量、票价、折扣信息等),已订票的客户名单(包括姓名、车次、证件编号、订票量)
⑵。
作为示意系统,全部数据可以只放在内存中;
⑶。 系统能实现的操作和功能如下:
a。 查询:根据旅客提出的终点站名输出下列信息:车次、日期、乘员定额、余票额、票价和折扣信息;
b 。 订票:根据客户提出的要求(车次号、订票数)查询该车次票额情况,若有余票,则为客户办理订票手续,输出座位号;若已满员或余票额少于订票额,则需重新询问客户要求。
c。 退票:根据客户提供的情况(日期、车次),为客户办理退票手续;。收起