CODEFORCES 399A
CODEFORCES
399A - Pages
Link to Ques - Codeforces 399A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import java.util.LinkedList; import java.util.Scanner; public class CF399A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); LinkedList<String> str = new LinkedList<>(); int n = sc.nextInt(); int p = sc.nextInt(); int k = sc.nextInt(); if(p-k>1) { str.add("<< "); } for(int i=p-k;i<=p+k;i++) { if(i==p && i>=1) { str.add("("+i+") "); } else if(i<=n && i>=1) { str.add(i+" "); } } if(p+k<n) { str.add(">>"); } for(int i=0;i<str.size();i++) System.out.print(str.get(i)); } } |
Comments
Post a Comment