Description
Do you remember the game in which we find difference among several similar pictures? Now we change it into digital version. There are N digits, same or different. Please find how many different digits there are among them and output the number.
Input
Each group of the first line is N (1<=N<=10000). The second line consists N integers.
Output
The number of different digits.
Sample Input
2
1 1
3
1 2 3
Sample Output
1
3
HINT
代码:
#include <iostream>
using namespace std;
void sort(int my[],int n){
int temp;
for(int i=0;i<n;i++)
for(int j=0;j<n-i-1;j++){
if(my[j]>my[j+1]){
temp=my[j];
my[j]=my[j+1];
my[j+1]=temp;
}
}
}
void fun(int my[],int n){
int count=n;
for(int i=0;i<n;i++){
if(my[i]==my[i+1])
count--;
}
cout<<count<<'\12';
}
int main(){
int n,i;
while(cin>>n){
int my[n];
i=0;
while(i<n){
cin>>my[i++];
}
sort(my,n);
fun(my,n);
i++;
}
return 0;
}
运行结果: