⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 binsort3.cpp

📁 datastucutre and algorithms, application, in C
💻 CPP
字号:
// bin sort on different criteria

#include <iostream>
#include "studentRecord4.h"
#include "chainWithBinSort.h"

inline int f1(studentRecord& s) {return s.exam1;}
inline int f2(studentRecord& s) {return s.exam2;}
inline int f3(studentRecord& s)
   {return s.exam1 + s.exam2 + s.exam3;}

int main(void)
{
   studentRecord x;
   chain<studentRecord> theChain;
   for (int i = 1; i <= 20; i++)
   {
      x.exam1 = i/2;
      x.exam2 = 20 - i;
      x.exam3 = rand() % 100;
      x.name = i;
      theChain.insert(0,x);
   }
   theChain.binSort(10, f1);
   cout << "Sort on exam 1" << endl;
   cout << "  " << theChain << endl;
   theChain.binSort(20, f2);
   cout << "Sort on exam 2" << endl;
   cout << "  " << theChain << endl;
   theChain.binSort(130, f3);
   cout << "Sort on sum of exams" << endl;
   cout << "  " << theChain << endl;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -