读书人

UVa10474 - Where is the Marble

发布时间: 2013-09-17 13:35:59 作者: rapoo

UVa10474 - Where is the Marble?

题目地址:点击打开链接

C++代码:

#include<iostream>#include <algorithm>using namespace std;const int maxsize=10010;int A[maxsize];int main(){int N,Q;int CAS=1;while (true){cin>>N>>Q;if(N==0&&Q==0)break;int i;for(i=0;i<N;++i)cin>>A[i];sort(A,A+N);cout<<"CASE# "<<CAS++<<":"<<endl;for(i=0;i<Q;++i){int key;cin>>key;int j;for(j=0;j<N;++j)if(A[j]==key)break;if(j<N)cout<<key<<" found at "<<j+1<<endl;elsecout<<key<<" not found"<<endl;}}return 0;}


读书人网 >编程

热点推荐