SHARE
TWEET

Untitled

a guest Aug 17th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Гришин  Tmsu    2
  2. Ардашев Tmsu    3
  3. Котов   Smdf    4
  4. Евсеев  Smdf    3
  5. Новиков LLsd    2
  6.      
  7. #include <iostream>
  8. #include <fstream>
  9. #include <cstring>
  10. #include <string>
  11.  
  12. using namespace std;
  13.  
  14. struct data_box
  15. {
  16.     char second_name[50];
  17.     char subject_name[50];
  18.     int subject_val;
  19. };
  20.  
  21. int main()  {
  22.     setlocale(LC_ALL, "Russian");
  23.  
  24.     struct data_box data_arr[4];
  25.  
  26.  
  27.     char data_second_name[50], data_subject_name[50];
  28.     int data_subject_val;
  29.  
  30.     int i,j = 0;
  31.  
  32.     std::ifstream data_file;
  33.     std::string str;
  34.  
  35.     data_file.open("data.txt");
  36.  
  37.     while (data_file >> data_second_name >> data_subject_name >> data_subject_val) {
  38.  
  39.         strcpy(data_arr[j].second_name, data_second_name);
  40.         strcpy(data_arr[j].subject_name, data_subject_name);
  41.  
  42.         data_arr[j].subject_val = data_subject_val;
  43.  
  44.         j++;
  45.     }
  46.     for (i = 0; i < (sizeof(data_arr)/sizeof(data_arr[0])); i++){
  47.         cout << data_arr[i].second_name;
  48.     }
  49.  
  50.  
  51.     data_file.close();
  52.  
  53.     return 0;
  54. }
  55.      
  56. ГришинАрдашевКотовЕвсеев
  57. Process returned -1073741819 (0xC0000005)   execution time : 9.177 s
  58. Press any key to continue.
  59.      
  60. #include <iostream>
  61. #include <fstream>
  62. #include <string>
  63. #include <vector>
  64.  
  65. using namespace std;
  66.  
  67. struct data_box
  68. {
  69.     string second_name;
  70.     string subject_name;
  71.     int subject_val;
  72. };
  73.  
  74. int main()
  75. {
  76.     setlocale(LC_ALL, "Russian");
  77.     vector<data_box> data_arr;
  78.  
  79.     ifstream data_file("data.txt");
  80.     if (!data_file.is_open()) exit(EXIT_FAILURE);
  81.  
  82.     data_box tmp;  
  83.     while(data_file >> tmp.second_name >> tmp.subject_name >> tmp.subject_val) {
  84.         data_arr.push_back(tmp);
  85.     }
  86.  
  87.     for (int i = 0; i < data_arr.size(); i++) cout << data_arr[i].second_name << endl;
  88.     return 0;
  89. }
  90.      
  91. int main()
  92. {
  93.     setlocale(LC_ALL, "Russian");
  94.     vector<data_box> data_arr;
  95.  
  96.     ifstream data_file("data.txt");
  97.     if (!data_file) exit(EXIT_FAILURE);
  98.  
  99.     data_box tmp;
  100.     while(data_file >> tmp.second_name >> tmp.subject_name >> tmp.subject_val) {
  101.         data_arr.push_back(move(tmp));
  102.     }
  103.  
  104.     for (const auto &data: data_arr) cout << data.second_name << endl;
  105.     return 0;
  106. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top