Advertisement
DMG

Histogram (S)

DMG
Apr 2nd, 2013
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. // dragutinmarjanovic
  2. #include <iostream>
  3. using namespace std;
  4. main()
  5. {
  6.       int n, a[1000], s;
  7.      
  8.       cin >> n;
  9.      
  10.       for (int i=0; i<n; i++)
  11.       cin >> a[i];
  12.      
  13.       for (int i=0; i<n; i++)
  14.       {
  15.          s = 1;
  16.           for (int j=i+1; j<n; j++)
  17.               if (a[i] == a[j])
  18.               {
  19.                        s = s + 1;
  20.                        a[j] = -1;
  21.               }
  22.           if (a[i]!=-1)
  23.              cout << a[i] << " " << s << endl;
  24.       }
  25.      
  26.       system ("PAUSE");      
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement