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; }
运行结果:
相关文章推荐
- Contest1376 - "师创杯"烟台大学第二届ACM程序设计精英赛复现Problem H: H-Sum 3s
- Contest1376 - "师创杯"烟台大学第二届ACM程序设计精英赛复现F-A Simple Question
- Contest1376 - "师创杯"烟台大学第二届ACM程序设计精英赛复现 A--A Repeating Characters
- Contest1376 - "师创杯"烟台大学第二届ACM程序设计精英赛复现Problem C: C-Z型变换
- 程序设计模式之"监听器模型"
- acm/icpc中国 辽宁省第二届大学生程序设计竞赛结束了
- 利用ftp服务程序本身设计的"缺陷"取得最高权限
- 第二届"春回燕归 浙籍精英峰会"见闻
- 身份证校验 如果让你设计个程序,用什么变量保存身份证号码呢?长整数可以吗?不可以! 因为有人的身份证最后一位是"X"
- "某个程序安装已在安装计算机上创建挂起的文件操作" 解决办法
- 升级IE弹出"以前的安装有尚未完成的操作,需要重新启动。建议在运行Internet Explorer安装程序之前重新启动计算机。现在安装程序将关闭"
- "分段好啊分段好"求最大M个数的程序 (上)2006-07-18
- "某个程序安装已在安装计算机上创建挂起的文件操作" 解决办法 另解
- "某个程序安装已在安装计算机上创建挂起的文件操作" 解决办法 另解
- 使用VS2003创建WEB程序的时候出现"AutoMation服务器不能创建对象"错误
- 未能在"设计"视图中打开.在""块中,以不同方式将值括起来的解决方案汇总
- 未能在"设计"视图中打开.在""块中,以不同方式将值括起来的解决方案汇总
- 打开文件->选择程序 出现"拒绝访问"
- 设计模式-OOD的设计原则(5)-"合成聚合复用原则"
- 安装Visual Studio 6的"Error Lauching acmboot.exe"问题解决方法