Codeforces Round #233 (Div. 2) A、Pages

OpenSoucre發表於2014-03-13
#include <iostream>
using namespace std;

int main(){
    int n,p,k;
    cin >> n >> p >> k;
    bool hasLeft = true, hasRight = true;
    int first = p-k,last = p + k;
    if( p - k <= 1) first = 1,hasLeft = false;
    if( p + k >= n) last = n,hasRight = false;
    if(hasLeft) cout<<"<< ";
    for(int i = first; i<= last; ++ i){
        if(i == p) cout<<"("<<p<<") ";
        else cout<<i<<" ";
    }
    if(hasRight) cout<<" >>"<<endl;
}

 

相關文章