欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 教育 > 幼教 > UVA-10474 大理石在哪儿(Where is the Marble?)

UVA-10474 大理石在哪儿(Where is the Marble?)

2025/9/27 13:09:20 来源:https://blog.csdn.net/qq_55069195/article/details/140904923  浏览:    关键词:UVA-10474 大理石在哪儿(Where is the Marble?)

UVA-10474 大理石在哪儿(Where is the Marble?)


1. 问题描述

UVA-10474 大理石在哪儿(Where is the Marble?)

2. 代码实现
// #define LOCAL
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;int main() {
#ifdef LOCALfreopen("UVA-10474.in", "r", stdin);freopen("UVA-10474.out", "w", stdout);
#endifint mar_num, query_num, game_num = 0;while (scanf("%d %d", &mar_num, &query_num) == 2 && mar_num != 0) {int mar, query;vector<int> number;cout << "CASE# " << ++game_num << ":" << endl;for (int i = 0; i < mar_num; i++) {scanf("%d", &mar);number.push_back(mar);}sort(number.begin(), number.end());for (int i = 0; i < query_num; i++) {scanf("%d", &query);for (int i = 0; i < number.size(); i++) {if (number[i] == query) {cout << query << " found at " << i + 1 << endl;break;}if (i == number.size() - 1)cout << query << " not found" << endl;}}}return 0;
}
3. 验证案例

数据来源

  • 输入

    10 5 1 
    1 
    3 
    5 
    7 
    1 
    3 
    9 
    120 
    1 1 
    3 
    120 
    7 
    1234 10 12 1111 
    1111 
    1111 
    5 
    5 
    5 
    10 
    11 
    12 
    10 1111 
    5 
    10 
    11 
    12 
    1111 
    134 
    567 
    246 
    24 
    12 
    435 
    0 0
    
  • 输出

    CASE# 1:
    1 found at 1
    3 found at 5
    120 found at 10
    7 found at 8
    1234 not found
    CASE# 2:
    1111 found at 8
    5 found at 1
    10 found at 4
    11 found at 6
    12 found at 7
    1111 found at 8
    134 not found
    567 not found
    246 not found
    24 not found
    12 found at 7
    435 not found

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词