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:\n",++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\n",temp,t+1);
32             }
33             else
34             {
35                 printf("%d not found\n",temp);
36             }
37         }
38     }
39     
40     return 0;
41 } 

优质内容筛选与推荐>>
1、《大道至简》读后感
2、wchar_t与char、wstring与string的相互转换
3、python网络基础_socket
4、ssh maven 搭建
5、Jquery+Asp.Net的ajax小测试


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号