更新 '1.c'
This commit is contained in:
parent
5a229e4bf0
commit
d7b258141f
18
1.c
18
1.c
@ -253,10 +253,11 @@ void Delete(SING sing[MAX], int *num){
|
||||
}
|
||||
*num=*num-1;
|
||||
}
|
||||
void sort_xuhao(SING sing[MAX], int num){
|
||||
void sort_xuhao(SING sing[MAX], int num, int n){
|
||||
SING temp;
|
||||
for(int i=0;i<num-1;i++){
|
||||
for(int j=0;j<num-1-i;j++){
|
||||
if(n==1){
|
||||
if(sing[j].num>sing[j+1].num){
|
||||
// 交换
|
||||
temp=sing[j];
|
||||
@ -264,9 +265,18 @@ void sort_xuhao(SING sing[MAX], int num){
|
||||
sing[j+1]=temp;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(sing[j].num<sing[j+1].num){
|
||||
// 交换
|
||||
temp=sing[j];
|
||||
sing[j]=sing[j+1];
|
||||
sing[j+1]=temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void sort_aver(SING sing[MAX], int num){
|
||||
void sort_aver(SING sing[MAX], int num, int n){
|
||||
SING temp;
|
||||
for(int i=0;i<num-1;i++){
|
||||
for(int j=0;j<num-1-i;j++){
|
||||
@ -293,10 +303,10 @@ void sort(SING sing[MAX], int num, int num_){
|
||||
scanf("%d",&n);
|
||||
switch(x){
|
||||
case 1:
|
||||
sort_xuhao(sing, num);
|
||||
sort_xuhao(sing, num, n);
|
||||
break;
|
||||
case 2:
|
||||
sort_aver(sing, num);
|
||||
sort_aver(sing, num, n);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user