|
|
1.1 ! root 1: #include "list.h" ! 2: ! 3: extern "C" { ! 4: int rand(); ! 5: void srand(); ! 6: } ! 7: ! 8: listdeclare(int) ! 9: ! 10: int bigger(int&, int&); ! 11: ! 12: main() ! 13: { ! 14: int_list myList; ! 15: const sz = 500; ! 16: int arr[sz]; ! 17: srand(); ! 18: for (int i=0; i<sz; i++) arr[i] = i; ! 19: for (i=sz; i; ) { ! 20: int j = rand() % i; ! 21: myList.put(arr[j]); ! 22: arr[j] = arr[--i]; ! 23: } ! 24: myList.sort(bigger); ! 25: cout << myList << "\n"; ! 26: } ! 27: ! 28: int ! 29: bigger(int& a, int& b) ! 30: { ! 31: return a < b; ! 32: } ! 33: ! 34: listimplement(int) ! 35: listoutimplement(int) ! 36: /* ! 37: int i; ! 38: while (cin >> i) ! 39: myList.put(i); ! 40: ! 41: const sz = 200; ! 42: int arr[sz]; ! 43: srand(); ! 44: for (int i=0; i<sz; i++) arr[i] = i; ! 45: for (i=sz; i; ) { ! 46: int j = rand() % i; ! 47: myList.put(arr[j]); ! 48: arr[j] = arr[--i]; ! 49: } ! 50: ! 51: for (int i=0; i<200; i++) ! 52: myList.put(i); ! 53: */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.