UVA 10474 Where is the Marble
来源:互联网 发布:查询域名对应的ip地址 编辑:程序博客网 时间:2024/06/06 11:29
UVA 10474 Where is the Marble?
题目大意:将给出的数字从小到大排序,并找到相应的数字是第几个
解题思路:qsort排序然后查找
#include <stdio.h>#include <iostream>#include <string.h>#include <algorithm>using namespace std;int num[10010];int num2[10010];int cmd(const void *a, const void *b) { return *(int*)a - *(int*)b;}int main() { int n, m, x = 0; while(cin >> n >> m && m + n != 0) { x++; for(int i = 0; i < n; i++) cin >> num[i]; for(int i = 0; i < m; i++) cin >> num2[i]; qsort(num, n, sizeof(int), cmd); printf("CASE# %d:\n", x); for(int i = 0; i < m; i++) { int a = num2[i]; int j; for(j = 0; j < n; j++) if(num[j] == a) break; if(j == n) printf("%d not found\n", a); else printf("%d found at %d\n", a, j+1); } } return 0;}
0 0
- UVa 10474 Where is the Marble?
- Uva 10474 Where is the Marble?
- uva 10474 Where is the Marble?
- UVA 10474 Where is the Marble?
- UVA 10474 - Where is the Marble
- uva-10474 - Where is the Marble?
- uva 10474 - Where is the Marble?
- UVA 10474 - Where is the Marble?
- UVa 10474 - Where is the Marble?
- UVa 10474 - Where is the Marble
- UVa 10474 - Where is the Marble?
- UVA 10474 Where is the Marble?
- UVA 10474 - Where is the Marble
- UVa - 10474 - Where is the Marble?
- uva 10474 Where is the Marble?
- uva 10474 Where is the Marble?
- uva - 10474 - Where is the Marble?
- uva 10474 - Where is the Marble
- C/C++怎样通过预定义宏识别编译器名称和版本
- Xcode-block
- HTML5入门大二下暑假总结---1
- 安装vs2010并配置opencv2.4.11笔记【2016-8】
- leetcode No103. Binary Tree Zigzag Level Order Traversal
- UVA 10474 Where is the Marble
- httpServletResponse简概
- 2016多校训练Contest10: 1001 Median hdu5857
- linux文件交集差集
- SQL Server 2014连接启动和停止服务器
- hibernate 记录
- 1001. 害死人不偿命的(3n+1)猜想 (15)
- Java并发编程:线程间协作的两种方式:wait、notify、notifyAll和Condition
- hdu 2602 Bone Collector