Petro_zzz

studenth_3110

Oct 31st, 2022
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #pragma once
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. struct Student{
  8.     string name;
  9.     int mark[31]{};
  10.  
  11.     void init(string str) {
  12.         int id_st = 0;
  13.         int id_en = 0;
  14.         string small_str;
  15.         int counter = 0;
  16.         for (int k = 0; k < str.length(); ++k) {
  17.             if (str[k] == '\t') {
  18.                 id_en = k;
  19.                 small_str = str.substr(id_st, id_en - id_st);
  20.                 if (counter == 0) {
  21.                     name = small_str;
  22.                 }
  23.                 else {
  24.                     mark[counter - 1] = atoi(small_str.data());
  25.                 }
  26.                 //cout << small_str << endl;
  27.                 id_st = id_en + 1;
  28.                 counter++;
  29.             }
  30.         }
  31.     }
  32. };
  33.  
  34.  
Advertisement
Add Comment
Please, Sign In to add comment