UVA10474 Where is the Marble?排序

Posted hemeiwolong

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UVA10474 Where is the Marble?排序相关的知识,希望对你有一定的参考价值。

参考:https://blog.csdn.net/q547550831/article/details/51326321

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <algorithm>
 4 using namespace std;
 5 #define N 10000
 6 int main()
 7 {
 8     int n,q,count=0;
 9 
10     while (scanf("%d %d",&n,&q)!=EOF)
11     {
12         if (n==0&&q==0)
13         {
14             break;
15          } 
16         int m[N];
17         int i;
18         for (i=0;i<n;i++)
19         {
20             scanf("%d",&m[i]);
21         }
22         sort(m,m+n);
23         printf("CASE# %d:
",++count);//此行要放在while前面!!! 
24         while (q--)
25         {
26             int temp;
27             scanf("%d",&temp);
28             int t=lower_bound(m,m+n,temp)-m;
29             if (m[t]==temp)
30             {
31                 printf("%d found at %d
",temp,t+1);
32             }
33             else
34             {
35                 printf("%d not found
",temp);
36             }
37         }
38     }
39     
40     return 0;
41 } 

 

以上是关于UVA10474 Where is the Marble?排序的主要内容,如果未能解决你的问题,请参考以下文章

UVA10474 Where is the Marble?排序

排序与检索UVa10474Where is the Marble?

D - Where is the Marble? (UVA - 10474)

A - Where is the Marble? UVA - 10474

大理石在哪儿 (Where is the Marble?,UVa 10474)

UVA10474 大理石在哪儿 Where is the Marble?