Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.72 KB | None | 0 0
  1. void wczytajDaneZProtokolu(string Protokol1, Student*& pHead1, Przedmiot*& pHead)
  2. {
  3.     fstream plik;
  4.  
  5.     plik.open(Protokol1);
  6.  
  7.     if (plik.good() == 0)
  8.     {
  9.         cout << "Plik jest bledny";
  10.         return;
  11.     }
  12.     else
  13.     {
  14.        
  15.  
  16.         Student* pomocniczy;
  17.         Student* nowyStudent;
  18.         Przedmiot* nowyPrzedmiot;
  19.         Przedmiot* pomocPrzedm;
  20.        
  21.        
  22.        
  23.         int n = 0;
  24.  
  25.         while (!plik.eof())
  26.         {
  27.             if (pHead) {
  28.                 pomocPrzedm = pHead;
  29.  
  30.                 while (pomocPrzedm)
  31.                 {
  32.                     if (pomocPrzedm->Nastepny == nullptr)
  33.                         pomocPrzedm = pomocPrzedm->Nastepny;
  34.                     else
  35.                         break;
  36.                 }
  37.                 nowyPrzedmiot = new Przedmiot;
  38.  
  39.                 pomocPrzedm->Nastepny = nowyPrzedmiot;
  40.  
  41.                 nowyPrzedmiot->Nastepny = nullptr;
  42.             }
  43.             else
  44.             {
  45.                 nowyPrzedmiot = new Przedmiot;
  46.  
  47.                 nowyPrzedmiot->Nastepny = nullptr;
  48.  
  49.                 pHead = nowyPrzedmiot;
  50.             }
  51.  
  52.             if (pHead1) {
  53.                 pomocniczy = pHead1;
  54.  
  55.                 while (pomocniczy)
  56.                 {
  57.                     if (pomocniczy->pNext == nullptr)
  58.                         pomocniczy = pomocniczy->pNext;
  59.                     else
  60.                         break;
  61.                 }
  62.                 nowyStudent = new Student;
  63.                
  64.                 pomocniczy->pNext = nowyStudent;
  65.                
  66.                 nowyStudent->pNext = nullptr;
  67.             }
  68.             else
  69.             {
  70.                 nowyStudent = new Student;
  71.  
  72.                 nowyStudent->pNext = nullptr;
  73.  
  74.                 pHead1 = nowyStudent;
  75.             }
  76.  
  77.             if (n == 0)
  78.             {
  79.                 getline(plik, pHead->Prowadzacy);
  80.                 n++;
  81.                 pHead->Prowadzacy;
  82.             }
  83.  
  84.             else if (n == 1)
  85.             {
  86.                 getline(plik, pHead->Nazwa);
  87.                 n++;
  88.                 cout << pHead->Nazwa;
  89.             }
  90.  
  91.             else
  92.             {
  93.                 plik >> pHead1->Imie >> pHead1->Nazwisko >> pHead1->Nr_Albumu >> pHead1->Ocena >> pHead1->Data;
  94.                 cout << pHead1->Imie << " " << pHead1->Nazwisko << " " << pHead1->Nr_Albumu << " " << pHead1->Ocena << " " << pHead1->Data;
  95.             }
  96.            
  97.            
  98.         }
  99.         n = 0;
  100.     }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement