10474 - Where is the Marble?
来源:互联网 发布:江苏省普通发票软件 编辑:程序博客网 时间:2024/05/23 20:00
题目:10474 - Where is the Marble?
题目大意:从小到大排序后找到指定数的位置。
解题思路:用sort()。
#include<stdio.h>#include<algorithm>using namespace std;const int N = 10005;int t, n, q, s1[N], s[N];int cmp(const int a, const int b) {return (a < b)? 1: 0;}int main () {while(scanf("%d %d", &n, &q)) {int i, j , count ;if(n == 0 && q == 0)break;printf("CASE# %d:\n", ++t);for ( i = 0 ; i < n; i++) {scanf("%d", &s[i]);}for( i = 0; i < q; i++) {scanf("%d", &s1[i]);}sort(s, s + n, cmp);for(i = 0; i < q; i++) {count = 0;for (j = 0; j < n; j++) {if(s1[i] == s[j]) {printf("%d found at %d\n", s1[i] , ++count);break;}elsecount++;}if(j == n)printf("%d not found\n", s1[i]);}}return 0;}
0 0
- 10474--Where is the Marble
- 10474 - Where is the Marble?
- 10474 - Where is the Marble?
- 10474 - Where is the Marble?
- 10474 - Where is the Marble?
- 10474Where is the Marble?
- 10474 - Where is the Marble?
- 10474 - Where is the Marble?
- 10474 - Where is the Marble
- 10474 - Where is the Marble?
- Where is the Marble
- Where is the Marble?
- Where is The Marble
- Where is the Marble?
- Where is the Marble?
- Where is the Marble?
- Where is the Marble?
- Where is the Marble?
- 【Java并发编程】之二十一:并发新特性—阻塞队列和阻塞栈(含代码)
- sublime弹出报错信息
- cocos2dx 常用的构建工具
- 使用DBLINK访问LOB类型表
- SQLServer数据库日志清理清除sqlserver2005日志
- 10474 - Where is the Marble?
- 二分查找
- 【转】软件反编译的方法
- Moon Game (凸四边形个数,数学题)
- jquery CheckBox、RadioButton、DropDownList的取值赋值实现代码/服务器控件 gridview 循环
- 奋斗
- awk 中 用“||“ 作为分隔符的方法
- Lance老师UI系列教程第一课->QQ设置界面的实现(android)
- [转]使用Go语言一段时间的感受