Advertisement
Spocoman

06. Squares

Jan 26th, 2024 (edited)
837
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4. #include <list>
  5. #include <cmath>
  6.  
  7. using namespace std;
  8.  
  9. int main() {
  10.     string line;
  11.     getline(cin, line);
  12.  
  13.     istringstream ss(line);
  14.  
  15.     list<int> numbers;
  16.  
  17.     int number;
  18.  
  19.     while (ss >> number) {
  20.         numbers.push_back(number);
  21.     }
  22.  
  23.     numbers.sort();
  24.  
  25.     for (auto i = numbers.rbegin(); i != numbers.rend(); i++) {
  26.         if ((double)sqrt(*i) == (int)sqrt(*i)) {
  27.             cout << *i << ' ';
  28.         }
  29.     }
  30.  
  31.     cout << endl;
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement