Look at a topic:
We thought there might be this: the input all the data is stored in an array, then a wave of bubble sort, from small to large
So how to find the number of repetitions of it: I think so, a new definition of the array b, the original array a, first b [0] = a [0 ], define a pointer to an array i a, j point to the original array b, the initial value is 0, if a [i] == b [j ], is a repeating element, then i ++, continue, else b [++ j] = a [ i ++]
This is a bit complicated, there is no simple approach?
Markup attribute array may be utilized: define arrays a, all assigned the value 0, then the input is k, then let a [k] ++, and finally print a [k]> 0 to
Code:
#include <bits/stdc++.h> using namespace std; int a[105] = {0}; int main () { int n,x; scanf("%d", &n); for(int i=0; i<n; i++){ scanf("%d", &x); a[x]++; } for(int i=0; i<n; i++){ if( a[i]>0 ){ printf ( "% d: number% d \ n appears", i, a [i]); } } return 0; }
result: