#import #import "teacher.h"
int main(int argc, const char * argv) ,,,
,};
int count = sizeof(teachers) / sizeof(teacher);
printf("輸入1:實現按照姓名進行公升序排列\n輸入2:實現按照姓名進行降序排列\n輸入3:實現按照員工編號進行公升序排列\n輸入4:實現按照員工編號進行降序排列\n輸入5:實現按照評分進行公升序排列\n輸入6:實現按照評分進行降序排列\n輸入7:實現輸出所有的女老師\n輸入8:實現輸出所有的男老師\n*************************===\n請輸入實現功能對應的數字:\n");
while (0 < 1) ;
int zhiling = 0;
scanf("%d",&zhiling);
switch (zhiling)
break;
case comparenamebydescending:
break;
case comparenumberbyascending:
break;
case comparenumberbydescending:
break;
case comparescorebyascending:
break;
case comparescorebydescending:
break;
case printmaleteacher:
break;
case printfemaleteacher:
break;
default: printf("對不起,您輸入的數字木有對應的函式,請重新輸入!!!\n");break;
}}
#import typedef struct teacher;
// 列印teacher函式
void printteacher(teacher *teacher);
typedef bool (*comparefunctionpointer) (teacher teacher1, teacher teacher2);
// 排序函式
void sortteachers(teacher teacher, int count, comparefunctionpointer cfp);
// 列印所有teacher的函式
void printteachers(teacher *teachers,int count);
// 比較teacher 姓名
bool comparenamebyascending(teacher teacher1, teacher teacher2);
bool comparenamebydescending(teacher teacher1, teacher teacher2);
// 比較員工編號
bool comparenumberbyascending(teacher teacher1, teacher teacher2);
bool comparenumberbydescending(teacher teacher1,teacher teacher2);
//比較員工評分
bool comparescorebyascending(teacher teacher1,teacher teacher2);
bool comparescorebydescending(teacher teacher1,teacher teacher2);
//輸出全部男老師
void printmaleteacher(teacher *teachers,int count);
// 輸出全部女老師
void printfemaleteacher(teacher *teacher, int count);
#import "teacher.h"
// 列印teacher函式
void printteacher(teacher *teacher)
// 排序函式
void sortteachers(teacher teacher, int count, comparefunctionpointer cfp)}}
}// 列印所有teacher的函式
void printteachers(teacher *teachers,int count)
}// 比較teacher 姓名
bool comparenamebyascending(teacher teacher1, teacher teacher2)
bool comparenamebydescending(teacher teacher1, teacher teacher2)
// 比較員工編號
bool comparenumberbyascending(teacher teacher1, teacher teacher2)
bool comparenumberbydescending(teacher teacher1,teacher teacher2)
//比較員工評分
bool comparescorebyascending(teacher teacher1,teacher teacher2)
bool comparescorebydescending(teacher teacher1,teacher teacher2)
//輸出全部男老師
void printmaleteacher(teacher *teachers,int count)}}
// 輸出全部女老師
void printfemaleteacher(teacher *teachers, int count)}}
排序比較演算法c
氣泡排序 時間複雜度 o n 2 o n 2 o n2 include include include using namespace std void bubblesort int arr,int len int main void cout endl bubblesort arr,20 for ...
C 排序演算法的比較
首先通過圖表比較不同排序演算法的時間複雜度和穩定性。排序方法 平均時間 最壞情況 最好情況 輔助空間 穩定性 直接插入排序 o n2 o n2 o n o 1 是氣泡排序 o n2 o n2 o n o 1 是簡單選擇排序 o n2 o n2 o n2 o 1 是希爾排序 o nlog2n o n2...
C 中氣泡排序和比較排序
比較排序 private static void sortnum int min array 0 int max array array.length 1 for int i 0 i array.length 1 i 最小值 依次用第乙個數和後面的數進行比較如果第乙個數大於第二個數則最小值為小的那個...