fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3. struct asd {
  4. int wsk;
  5. int count;
  6. asd() {wsk=0;count=0;}
  7. };
  8. int main() {
  9. int data[50];
  10. asd lista[50];
  11. int i=0,how_many=0;
  12. while (cin >> data[i]) {
  13. how_many++;
  14.  
  15.  
  16. for(int j=0;j<how_many;j++) {
  17. //if a number happens to be first of its kind
  18. if(lista[j].wsk==0 && lista[j].count == 0) {lista[j].wsk=data[i];lista[j].count++; break;}
  19. else if (lista[j].wsk== data[i]) {lista[j].count++; break;}
  20. }
  21. ++i; //must be here, else It'd assign some random memory adress (cause it would point to thing that hasnt been yet processed)
  22. }
  23. for(int p=0;p<how_many;p++)
  24. cout << lista[p].wsk << " " << lista[p].count <<"\n";
  25.  
  26.  
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0s 3300KB
stdin
-12 3 -12 4 1 1 -12 1 -1 1 2 3 4 2 3 -12
stdout
-12 4
3 3
4 2
1 4
-1 1
2 2
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0