UVA 10474-Where is the Marble?
来源:互联网 发布:php xml 特殊字符转义 编辑:程序博客网 时间:2024/06/05 15:14
UVA 10474-Where is the Marble?
题目大意:先输入 2 个数字,一个是被查找的元素个数,一个是需要查找的元素个数,然后输入元素,如果输入 0 则结束,然后将被查找元素排序后查找
解题思路:先排序,然后找出元素所在位置
#include <stdio.h>#include <iostream>using namespace std;int main() { int m, n; int a[100000]; int b; int all = 0; while(scanf("%d%d", &m, &n) && m != 0 && n != 0) { all++; for(int i = 0; i < m; i++) scanf("%d", &a[i]); for(int i = 0; i < m - 1; i++) for(int j = 0; j < m - i -1; j++) if(a[j] >= a[j+1]) { int t = a[j]; a[j] = a[j+1]; a[j+1] = t; } printf("CASE# %d:\n", all); for(int i = 0; i < n; i++) { scanf("%d", &b); int x = 0; for(int j = 0; j < m; j++) { x++; if(a[j] == b) { printf("%d found at %d\n", b, x); x = -1; break; } } if(x != -1) printf("%d not found\n", b); } } 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?
- Android收集应用崩溃信息
- Python——5函数
- hdu 5726 GCD(2016 Multi-University Training Contest 1线段树)
- CODEFORCES 450D Jzzhu and Cities <最短路径>
- 人民币即期汇率近六年首次跌破6.70 对国际消费影响几何
- UVA 10474-Where is the Marble?
- [HDU 5726] GCD (倍增法+二分)
- AFNetworking2安全的使用自签证书访问HTTPS
- HDU 3555 Bomb
- Java编程基础
- python3的函数调用
- MySQL之聚合函数查询
- 安卓中QQ登陆源代码
- 自定义圆形QLabel控件