Advertisement
barbos01

arbori

May 29th, 2022
824
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8.     int i,n,st[100],dr[100];
  9.     ifstream fin("date.in");
  10.     ofstream fout("date.out");
  11.  
  12.     fin>>n;
  13.     for(i=1;i<=n;i++)
  14.         fin>>st[i]>>dr[i];
  15.     fout<<"frunzele: ";
  16.     for(i=1;i<=n;i++)
  17.         if(st[i]==0 && dr[i]==0) fout<<i<<" ";
  18.     fout<<"\nvarfurile cu un singur descendent: ";
  19.     for(i=1;i<=n;i++)
  20.         if(st[i]*dr[i]==0 && st[i]+dr[i]!=0) fout<<i<<" ";
  21.     fout<<"\nvarfurile cu doi descendenti: ";
  22.     for(i=1;i<=n;i++)
  23.         if(st[i] && dr[i]) fout<<i<<" ";
  24.     fin.close();
  25.     fout.close();
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement