这个C++程序怎么改?

[复制链接]
查看11 | 回复1 | 2008-11-10 12:59:08 | 显示全部楼层 |阅读模式
函数void sort(T items[],int low,int high)的功能是:对items结构数组中从下标low开始到high为止的所有数组元素按成员name以字典序排序,并输出排序后的结果。
#include "iostream.h"
#include "string.h"
struct T
{
char name[20],num[20];
}
void sort(T items[],int low,int high)
{
T temp; int k,j;
for(k=low;kitems[j].name)
{temp=items[k];item[k]=items[j];items[k]=temp;}
}
void main()
{
T stu[4]={"Wang","6723","Cai","2106","Zhang","5129","Chang","4512","An","6868"};
int k;
sort(stu,0,4);
coutnamenum struct T { char name[20]; char num[20]; }; void sort(struct T items[],int low,int high) { struct T temp; int k,j; ...
回复

使用道具 举报

千问 | 2008-11-10 12:59:08 | 显示全部楼层
#include "iostream.h" #include "string.h" struct T {char name[20],num[20]; } ;//忘记分号void sort(T items[],int low,int high) {T temp; int k,j;for(k=low;k<high;...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行