UVA 10474 - Where is the Marble?
来源:互联网 发布:json字符串中url编码 编辑:程序博客网 时间:2024/06/05 17:23
题目大意:给出 n 个数 和 m 个要查找的数,让你在这 n 个数排完序后的队伍中 找出这个 m 个数第一次出现的位置
解题思路:直接从 n 个数出查找是否存在这个数,并记录所有比他小的数的个数,这个数加一就是它在排完序后在队伍中位置
#include <cstdio>int main() {int n, m;int count = 0;while (scanf("%d%d", &n, &m), n) {printf("CASE# %d:\n", ++count);int arr[10010], brr[10010];for (int i = 0; i < n; i++)scanf("%d", &arr[i]);for (int i = 0; i < m; i++) {scanf("%d", &brr[i]);int num = 0, ok = 0;for (int j = 0; j < n; j++) {if (brr[i] == arr[j]) //判断队伍中是否存在此数ok = 1;if (brr[i] > arr[j]) //寻找此数在排序完的队伍中第一次出现的位置num++;}ok ? printf("%d found at %d\n", brr[i], num + 1) : printf("%d not found\n", brr[i]);}}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
- MakeFile基础知识(五)
- 警惕!iPhone 6即将上市 诈骗邮件已现身网络
- java跳出多重循环
- hdu 3766 Knight's Trip
- android基础笔记:显示意图并传递简单参数
- UVA 10474 - Where is the Marble?
- Android Gralloc模块分析--深入分析
- keychain应用
- 对hibernate懒加载的理解
- git命令
- 【代码备忘】VC判断自己窗口的另一种方法
- 上学的时候Java写的打字练习
- import 语句的模块顺序
- HWOJ-字符串运用-密码截取