九度题目1018(Hash)
来源:互联网 发布:linux kvm虚拟化 编辑:程序博客网 时间:2024/05/19 16:28
#include <stdio.h>
int main(){
int n;
int buf[101];
int i;
int x;
while(scanf("%d",&n)!=EOF&&n!=0){
for(i=0;i<101;i++){
buf[i]=0;
}
for(i=0;i<n;i++){
scanf("%d",&x);
buf[x]++;
}
scanf("%d",&x);
printf("%d\n",buf[x]);
}
return 0;
int main(){
int n;
int buf[101];
int i;
int x;
while(scanf("%d",&n)!=EOF&&n!=0){
for(i=0;i<101;i++){
buf[i]=0;
}
for(i=0;i<n;i++){
scanf("%d",&x);
buf[x]++;
}
scanf("%d",&x);
printf("%d\n",buf[x]);
}
return 0;
}
注意:
1.以上为Hash思路
2.buf数组赋初值的时候,也是要在while循环里
3.数组初始为零也可以写为int buf[101]={0};
0 0
- 九度题目1018(Hash)
- 九度:1018<Hash>
- 九度OJ 题目1018:统计同成绩学生人数(利用Hash)
- 九度题目1018
- 九度OJ 题目1018
- 九度考研机试教程 11-题目1431:Sort hash
- 九度考研真题 清华 2011-3清华题目1088:剩下的树 hash
- 九度王道考研机试真题 2011-2北大题目1156:谁是你的潜在朋友 hash
- 九度1283(字符串+hash)
- 九度题目1202
- 九度题目1061
- 九度题目1185
- 九度题目1023
- 九度题目1054
- 九度题目1096
- 九度题目1043
- 九度题目1070
- 九度题目1186
- 项目记录22-- tolua基于lua框架事件派发
- Java三层与MVC的区别
- ITOO-解决通过sql语句无法实现分页
- Date
- linux命令行
- 九度题目1018(Hash)
- DPM(voc-release5) Matlab模型文件 Mat转XML
- 1100. Mars Numbers (20)
- Tomcat 的设计模式分析
- 编程论坛排名
- EJB-JMS
- 团队建设系列—制定流程规范
- iOS海哥开发笔记 (海哥原创,常用的设计模式MVC,单例,代理,KVO)
- PHP学习笔记1-基础知识