#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 1000;
int main(){
int n, q, x, a[maxn],kase = 0;
while(scanf("%d%d",&n,&q) == 2 && n){//n为大理石的个数,q为所要查询的个数
printf("case # %d\n",kase++);
for(int i = 1;i <= n; i++)
scanf("%d",&a[i]);
sort(a,a+n);//sort函数的使用方法
while(q--){
scanf("%d",&x);
int p = lower_bound(a,a+n,x) - a;//lowerbound的使用方法
if(a[p] == x)
printf("%d fonud at %d\n",x,p+1);
else
printf("%d not found");
}
}
return 0;
}
/*
*输入一个文本,找出所有不同的单词,按字典序从小到大输出
*/
#include<iostream>
#include<string>
#include<set>
#include<sstream>
using namespace std;
set<string> dict;//string集合
int main(){
string s,buf;
while(cin >> s){
for(int i = 0; i < s.length(); i++)
if(isalpha(s[i]))
s[i] = tolower(s[i]);
else
s[i] = ' ';
stringstream ss(s);
while(ss >> buf)
dict.insert(buf);
for(set<string>::iterator it = dict.begin();it != dict.end(); ++it)
cout << *it << "\n";
return 0;
}
}
/*映射是从键到值的映射,输入一些单词,找出所有满足以下条件的单词:该单词不能通过字母重排,
*得到输入文本中的另外一个单词。在判断是否满足条件时,字母不分大小写,但在输出时应该保留输入中
*的大小写,按字典序排列--->为保证重排后得不到另一个单词,则
*/
#include<iostream>
#include<string>
#include<cctype>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
map<string,int> cnt;
vector<string> words;
//将单词标准化(按字典顺序)
string repr(const string &a){
string ans = s;
for(int i = 1; i < ans.length(); i++)
ans[i] = tolower(ans[i]);
sort(ans.begin(), ans.end());
return ans;
}
int main(){
int n = 0;
string s;
while(cin >> s){
if(s[0] == '#') break;
words.push_back(s);
string r = repr(s);
if(!cnt.count(r))
cnt[r] = 0;
cnt[r]++;//1表示不存在,即可以写入(0表示存在.)
}
/*第二次筛选*/
vector<string> ans;
for(int i = 0; i < words.size(); i++){
if(cnt[repr(words[i])] == 1)
ans.push_back(words[i]);
}
sort(ans.begin() , ans.end());
for(int i = 0; i < ans.size(); i++){
cout<< ans[i]<<"\n";
}
return 0;
}
#include<algorithm>
using namespace std;
const int maxn = 1000;
int main(){
int n, q, x, a[maxn],kase = 0;
while(scanf("%d%d",&n,&q) == 2 && n){//n为大理石的个数,q为所要查询的个数
printf("case # %d\n",kase++);
for(int i = 1;i <= n; i++)
scanf("%d",&a[i]);
sort(a,a+n);//sort函数的使用方法
while(q--){
scanf("%d",&x);
int p = lower_bound(a,a+n,x) - a;//lowerbound的使用方法
if(a[p] == x)
printf("%d fonud at %d\n",x,p+1);
else
printf("%d not found");
}
}
return 0;
}
/*
*输入一个文本,找出所有不同的单词,按字典序从小到大输出
*/
#include<iostream>
#include<string>
#include<set>
#include<sstream>
using namespace std;
set<string> dict;//string集合
int main(){
string s,buf;
while(cin >> s){
for(int i = 0; i < s.length(); i++)
if(isalpha(s[i]))
s[i] = tolower(s[i]);
else
s[i] = ' ';
stringstream ss(s);
while(ss >> buf)
dict.insert(buf);
for(set<string>::iterator it = dict.begin();it != dict.end(); ++it)
cout << *it << "\n";
return 0;
}
}
/*映射是从键到值的映射,输入一些单词,找出所有满足以下条件的单词:该单词不能通过字母重排,
*得到输入文本中的另外一个单词。在判断是否满足条件时,字母不分大小写,但在输出时应该保留输入中
*的大小写,按字典序排列--->为保证重排后得不到另一个单词,则
*/
#include<iostream>
#include<string>
#include<cctype>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
map<string,int> cnt;
vector<string> words;
//将单词标准化(按字典顺序)
string repr(const string &a){
string ans = s;
for(int i = 1; i < ans.length(); i++)
ans[i] = tolower(ans[i]);
sort(ans.begin(), ans.end());
return ans;
}
int main(){
int n = 0;
string s;
while(cin >> s){
if(s[0] == '#') break;
words.push_back(s);
string r = repr(s);
if(!cnt.count(r))
cnt[r] = 0;
cnt[r]++;//1表示不存在,即可以写入(0表示存在.)
}
/*第二次筛选*/
vector<string> ans;
for(int i = 0; i < words.size(); i++){
if(cnt[repr(words[i])] == 1)
ans.push_back(words[i]);
}
sort(ans.begin() , ans.end());
for(int i = 0; i < ans.size(); i++){
cout<< ans[i]<<"\n";
}
return 0;
}