include<stdio.h>#include<string.h>void sort(int a[], char b[][11])//a为数组地址{int i, j,v;char s[11];for(i = 0; i < 9; i ++)for(j = i+1; j<10; j ++){if(a[i] > a[j]){v = a[i];a[i] = a[j];a[j] = v;strcpy(s,b[i]);strcpy(b[i]...
&score[i][0]);//成绩的1号元素存姓名的下标,这样就把姓名和成绩关联起来了score[i][1] = i;}//对成绩进行排序for(i = STUNUM ; i > 1; i--)for(j = 1; j < i; j++){//按照成绩排序,同时将成绩对应的人进行调整if(score[j-1][0] > score[j][0]){tmp[0] = score...
1//排序案列2//描述:将person自定义数据类型进行排序,Person中有属性 姓名,年龄,身高3//排序规则: 按照年龄进行的升序,如果年龄相同按照身高进行降序45#include<iostream>6#include<string>7#include<algorithm>8#include<list>910usingnamespacestd;111213//person类14classPerson15{16public:17Person(stringname,int...
include <stdio.h> typedef struct student { char name[10];int year;int yearsold;}student;void main(){ student stu[10];student temp;int i, j;for (i = 0; i != 10; ++i){ scanf("%s %d", stu[i].name, &stu[i].year);stu[i].yearsold = 2011 - stu[i].year;} f...
void sortInfo(student** p,int num) {//选择排序,大的往前移 student* temp;int i,j,k;for(i=0;i<num;i++) { k = i;for(j=i+1;j<num;j++) { if(p[j]->score > p[k]->score)k = j;if(k!=i) {//交换p[i]和p[k]temp = p[i];p[i] = p[k];p[k] = ...
68{69cout <<"姓名:"<< (*it).m_Name <<"年龄:"<< it->m_Age <<"身高:"<< it->m_Height <<endl;7071}7273//排序74cout <<"---"<<endl;75cout <<"排序后:"<<endl;7677L1.sort(comparePerson);78for(list<Person>::iterator it = L1.begin(); it != L1.end(); it++)79{80cout...