标签:排序 必须 png 位置 程序 查找 name search bin
int n1[]={1,2,2,3,3,4,5};
int n2[]={5,4,3,3,2,2,1};
if(binary_search(n1,n1+7,3))
cout<<1<<"\n";
if(binary_search(n1,n1+7,8))
cout<<2<<"\n";
cout<<n1[upper_bound(n1,n1+7,3)-n1]<<"\n";
cout<<n1[lower_bound(n1,n1+7,3)-n1]<<"\n";
bool cmp(int a,int b)
{
return a<b;
}
bool cmp(int a,int b)
{
return a>b;
}
cout<<n2[upper_bound(n2,n2+7,3,cmp)-n2]<<"\n";
cout<<n2[lower_bound(n2,n2+7,3,cmp)-n2]<<"\n";
#include <bits/stdc++.h>
using namespace std;
bool cmp(int a,int b)
{
return a>b;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n1[]={1,2,2,3,3,4,5};
int n2[]={5,4,3,3,2,2,1};
if(binary_search(n1,n1+7,3))
cout<<1<<"\n";
if(binary_search(n1,n1+7,8))
cout<<2<<"\n";
cout<<n1[upper_bound(n1,n1+7,3)-n1]<<"\n";
cout<<n1[lower_bound(n1,n1+7,3)-n1]<<"\n";
cout<<n2[upper_bound(n2,n2+7,3,cmp)-n2]<<"\n";
cout<<n2[lower_bound(n2,n2+7,3,cmp)-n2]<<"\n";
}
标签:排序 必须 png 位置 程序 查找 name search bin
原文地址:https://www.cnblogs.com/baccano-acmer/p/9960281.html