爱奇艺编程题:区间表达

题目:https://www.nowcoder.com/practice/826c2f28ee2a414cac87eb0304eca1a0?tpId=90&tqId=30797&tPage=2&rp=2&ru=/ta/2018test&qru=/ta/2018test/question-ranking

#include

using namespace std;

int func(vector &num){

int n = num.size();

int i = 0,j = 0;

int ret = 0;

while(i < n){

j = i + 1;

while(j < n && num[i] + 1 == num[j]){

i = j;

if(j == n-1){

++ret;

return ret;

}

++j;

}

++ret;

i = j;

}

return ret;

}

int main(){

int n;

while(cin >> n){

vector num(n);

for(auto i = 0;i < n;++i)

cin>>num[i];

cout<

}

return 0;

}

你可能感兴趣的:(爱奇艺编程题:区间表达)