您的位置:首页 > 其它

Contest1376 - "师创杯"烟台大学第二届ACM程序设计精英赛复现 B--Faultfinding

2015-04-08 16:05 344 查看

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
;
        i=0;
        while(i<n){
            cin>>my[i++];
        }
        sort(my,n);
        fun(my,n);
        i++;
    }

    return 0;
}


运行结果:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐