Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //這根本不是二分 只是題目叫二分不要參考
- #include <iostream>
- #include <string>
- #include <iomanip>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int n,q,num=0;
- int main ()
- {
- while(cin>>n>>q)
- {
- if(n!=0&&q!=0)
- {
- num++;
- cout<<"CASE # "<<num<<":\n";
- int in[n];
- for(int i=0;i<n;i++)
- {
- cin>>in[i];
- }
- sort(in,in+n);
- int sear;
- for(int i=0;i<q;i++)
- {
- cin>>sear;
- bool find=0;
- for(int j=0;j<n;j++)
- {
- //cout<<in[j]<<endl;
- if(in[j]==sear)
- {
- cout<<sear<<" found at "<<j+1<<endl;
- find=1;
- break;
- }
- }
- if(!find)
- {
- cout<<sear<<" not found\n";
- }
- }
- }
- else
- return 0;
- }
- }
Add Comment
Please, Sign In to add comment