Advertisement
ioana_martin98

Untitled

May 11th, 2021 (edited)
757
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include<fstream>
  3.  
  4. using namespace std;
  5. typedef struct {
  6.     char nume[30];
  7.     char an;
  8.     int grupa;
  9.     char nrd;
  10.     char note[15];
  11. }STUDENT;
  12.  
  13. void main()
  14. {
  15.     ofstream f;
  16.     STUDENT x;
  17.  
  18.     char nume_f[20];
  19.     int i;
  20.  
  21.     cout << "\Nume fisier:";
  22.     cin >> nume_f;
  23.     f.open(nume_f);
  24.  
  25.     if (!f)
  26.         cout << "\nFisierul " << nume_f << " nu poate fi deschis";
  27.     else
  28.     {
  29.         //citire articol
  30.         cout << "\nNume: ";
  31.         cin >> x.nume;
  32.         cout << "An: ";
  33.         cin >> x.an;
  34.         cout << "Grupa: ";
  35.         cin >> x.grupa;
  36.         cout << "Numar discipline: ";
  37.         cin >> x.nrd;
  38.        
  39.         for (i = 0; i < (int)x.nrd-48; i++)
  40.         {
  41.             cout << "\nNota " << i << " = ";
  42.             cin >> x.note[i];
  43.         }
  44.         //adaugare articol citit de la tastatura
  45.         f << x.nume << " " << x.an << " " << x.grupa << " " << x.nrd << " ";
  46.         for (i = 0; i < (int)x.nrd-48; i++)
  47.             f << x.note[i]<<" ";
  48.         f.close();
  49.     }
  50.     cout << "\nAdaugarea s-a terminat";
  51.     cout << "\nApasa o tasta";
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement