Advertisement
Spocoman

01. Count Real Numbers

Jan 22nd, 2024 (edited)
869
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. #include <map>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.     string line;
  10.     getline(cin, line);
  11.  
  12.     map<double, int> numbers;
  13.  
  14.     istringstream ss(line);
  15.  
  16.     double number;
  17.  
  18.     while (ss >> number) {
  19.         numbers[number]++;
  20.     }
  21.  
  22.     for(auto& n : numbers) {
  23.         cout << n.first << " -> " << n.second << endl;
  24.     }
  25.  
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement