hopingsteam

Tutoriale-Pe.NET - Problema propusa

May 15th, 2019
124
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include    <iostream>
  2. #include    <fstream>
  3. #include    <cmath>
  4.  
  5. using namespace std;
  6.  
  7. ifstream fin("bac.txt");
  8.  
  9. bool ePatrat(int nr) {
  10.     if(int(sqrt(nr)) == sqrt(nr))
  11.         return true;
  12.     return false;
  13. }
  14. int main()
  15. {
  16.     int V[1000], total = 0;
  17.     int coord_start = -1, coord_end = -1;
  18.  
  19.     while(fin >> V[++total])
  20.     {
  21.         if(ePatrat(V[total]) && coord_start == -1)
  22.             coord_start = total;
  23.         else if(ePatrat(V[total]) && coord_start != -1)
  24.             coord_end = total;
  25.     }
  26.  
  27.     int lungimea = coord_end - coord_start + 1;
  28.    
  29.     cout << lungimea << "\n";
  30.     for(int i = coord_start; i <= coord_end; i++)
  31.         cout << V[i] << " ";
  32. }
RAW Paste Data