标签:itemid ios 排序 name show space amp problem index.php
C++ 11代码如下:
1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 int num[10000]; 5 int main() { 6 int q, n, t,k=0; 7 while ((cin >> n >> q) && n != 0) { 8 cout << "CASE# " << ++k << ‘:‘ << endl; 9 for (int i = 0; i < n; i++) cin >> num[i]; 10 sort(num, num + n); //默认升序 11 while (q--) { 12 cin >> t; 13 int p = lower_bound(num, num + n, t) - num; //lower_bound输出大于或者等于t的第一个位置,下面还需判断此位置处元素是否等于t 14 if (num[p] == t) cout << t << " found at " << p+1 << endl; //大理石从1开始排序,所以输出p+1 15 else cout << t << " not found" << endl; 16 } 17 } 18 return 0; 19 }
标签:itemid ios 排序 name show space amp problem index.php
原文地址:https://www.cnblogs.com/pgzhang/p/9267807.html