#include <stdio.h>
void sort( int * p, int n) {
int min, pos, aux;
for ( int i = 0 ; i < n - 1 ; i++ ) {
min = p[ i] ;
pos = i;
for ( int j = i + 1 ; j < n; ++ j) {
if ( p[ j] < min) {
min = p[ j] ;
pos = j;
}
}
aux = p[ pos] ;
p[ pos] = p[ i] ;
p[ i] = aux;
}
}
int main( int argc, char const * argv[ ] ) {
int vec[ 100 ] , n,
arr[ 100 ] , freq[ 100 ] , k = 0 ;
for ( int i
= 0 ; i
< n
; ++ i
) scanf ( "%d" , & vec
[ i
] ) ; for ( int i
= 0 ; i
< n
; ++ i
) printf ( "%d " , vec
[ i
] ) ; sort( vec, n) ;
arr[ k] = vec[ k] ;
freq[ k] = 1 ;
for ( int i = 0 ; i < n - 1 ; i++ ) {
if ( vec[ i] == vec[ i+ 1 ] ) {
freq[ k] ++;
} else {
k++;
arr[ k] = vec[ i+ 1 ] ;
freq[ k] = 1 ;
}
}
for ( int i = 0 ; i <= k; i++ ) {
if ( freq
[ i
] == 1 ) printf ( "Elementul %d apare o singura data!\n " , arr
[ i
] ) ; else
printf ( "Elementul %d apare de %d ori!\n " , arr
[ i
] , freq
[ i
] ) ; }
return 0 ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp2b2lkIHNvcnQoaW50ICpwLCBpbnQgbikgewogICAgIGludCBtaW4sIHBvcywgYXV4OwogICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuIC0gMTsgaSsrKSB7CiAgICAgICAgIG1pbiA9IHBbaV07CiAgICAgICAgIHBvcyA9IGk7CiAgICAgICAgIGZvcihpbnQgaiA9IGkgKyAxOyBqIDwgbjsgKytqKSB7CiAgICAgICAgICAgICBpZihwW2pdIDwgbWluKSB7CiAgICAgICAgICAgICAgIG1pbiA9IHBbal07CiAgICAgICAgICAgICAgIHBvcyA9IGo7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICAgICAgYXV4ID0gcFtwb3NdOwogICAgICAgICBwW3Bvc10gPSBwW2ldOwogICAg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