若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。


  • 运维

  • 前端

  • 编程

  • 随笔

  • hust-oj

2904: B–Faultfinding

发表于 2017-10-06   |   分类于 HUSTOJ   |   阅读次数 1,221

题目描述

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 s,a[10000],n=1,i,j;
    while (~scanf("%d",&s)&&s) 
    {
        for (i=0; i<s; i++)scanf("%d",a+i);
        for (i=1; i<s; i++)
                    for (j=i-1; j>=0; j--) 
        {
            if (a[j]==a[i])break;
            if (j==0)n++;
        }
        printf("%dn",n);
    }
    return 0;
}

解析

暂无

hustoj

发表评论 取消回复

邮箱地址不会被公开。 必填项已用*标注

*
*


hoxis wechat
著作权归作者所有
站点更新说明
  • 文章目录
  • 站点概览
若是凉夜已成梦

若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。

1904 日志
6 分类
12 标签
RSS
weibo github twitter facebook

友情链接

Dreams孤独患者 Skip 原站点
© 2017 若是凉夜已成梦
Powered by WordPress | 已运行
Theme By NexT.Mist