首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

UVa10474 - Where is the Marble

2013-09-17 
UVa10474 - Where is the Marble?题目地址:点击打开链接C代码:#includeiostream#include algorithmusi

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;}


热点排行