内存:128  时间:1

题目描述

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.

输入

Each group of the first line is N (1<=N<=10000). The second line consists N integers.

输出

The number of different digits.

样例输入

2
1 1
3
1 2 3

样例输出

1
3

提示

代码如下

#include<stdio.h>
int main()
{
    int n;
    int i,t,j;
    int x=0,y=0;
    int a[999];
    while(scanf("%d",&n)!=EOF)
    {
        y=0;
        for(i=1;i<=n;i++)
        {
            x=0;
            scanf("%d",&a[i]);
            for(j=1;j<i;j++)
            {
                if(a[j]==a[i])
                 x++;
            }
            if(x==0)y++;
        }
        printf("%d
",y);
    }
    return 0;
}

代码来源于互联网,仅供参考!