Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <cstring>
  4. #include <ctime>
  5. #include <algorithm>
  6. #include <functional>
  7.  
  8. using namespace std;
  9.  
  10. struct macierze {
  11.  
  12. string name;
  13. vector<vector<float>> mac;
  14.  
  15. };
  16. void randomize(macierze& x) {
  17.  
  18. for (int j = 0; j < 4; j++) {
  19. int w = rand() % 10;
  20. x.mac.push_back(vector<float>(5, w));
  21. }
  22.  
  23. }
  24.  
  25. void rand_name(macierze& x) {
  26. char w = rand() % 97 + 26;
  27. x.name = w;
  28. }
  29.  
  30.  
  31. void output(macierze x) {
  32. for (int i = 0; i < x.mac.size(); i++) {
  33. for (int j = 0; j < x.mac[i].size(); j++) {
  34. cout << x.mac[i][j] << "\t";
  35. }
  36. cout << endl;
  37. }
  38. }
  39. void compare(vector<macierze>& vec_of_mac) {
  40.  
  41. }
  42. int main() {
  43.  
  44. srand(time(NULL));
  45.  
  46. int i;
  47.  
  48. vector<macierze> vec_of_mac;
  49.  
  50. for (i = 1; i < 21; i++) {
  51.  
  52. macierze i;
  53. randomize(i);
  54. output(i);
  55. vec_of_mac.push_back(i);
  56.  
  57. }
  58. void sort(vec_of_mac[1].name, vec_of_mac[20].name, greater < 'char' >());
  59.  
  60. cout << endl;
  61. for (int j = 1; j < 21; j++) {
  62. cout << vec_of_mac[j].name << "\t";
  63. }
  64.  
  65. system("PAUSE");
  66. return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement