print_result:(result,v)={ifresult==v.end(){std::cout<<"Sequence not found\n";}else{pos:=std::distance(v.begin(),result);std::cout<<"Last occurrence is at: (pos)$\n";}}main:()={v:conststd::array=(1,2,3,4,1,2,3,4,1,2,3,4);for(:std::array=(1,2,3),:std::array=(4,5,6))do(x){iter:=std::find_end(v.begin(),v.end(),x.begin(),x.end());print_result(iter,v);}for(:std::array=(-1,-2,-3),:std::array=(-4,-5,-6))do(x){iter:=std::find_end(v.begin(),v.end(),x.begin(),x.end(),:(x:int,y:int)std::abs(x)==std::abs(y));print_result(iter,v);}}
Output
Last occurrence is at: 8
Sequence not found
Last occurrence is at: 8
Sequence not found