fork download
  1. package com.company;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.InputStreamReader;
  5. import java.util.Scanner;
  6.  
  7. public class Problem2 {
  8.  
  9. public static void main(String args[]) throws Exception {
  10. Scanner s = new Scanner(System.in);
  11. int n = s.nextInt();
  12. while (n-- > 0) {
  13. int N = s.nextInt();
  14. int Q = s.nextInt();
  15. int[] a1 = new int[N];
  16. int j = 0;
  17. String str = s.nextLine();
  18. for (int i = 0; i < str.length(); i += 2) {
  19. a1[j] = str.charAt(i);
  20. }
  21. leftRotate(a1, Q, N);
  22. for (int k = 0; k < N; k++)
  23. System.out.println(a1[k] + " ");
  24. }
  25. }
  26.  
  27. private static void leftRotate(int[] a, int q, int i) {
  28. for (int l = 0; l < i; l++)
  29. leftRotateByOne(a, i);
  30. }
  31.  
  32. private static void leftRotateByOne(int[] a, int i) {
  33. int temp = a[0], m;
  34. for(m=0; m<i-1; m++){
  35. a[m]=a[m+1];
  36. }
  37. a[m] = temp;
  38. }
  39. }
  40.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
2
5 2
1 2 3 4 5 
10 3
2 4 6 8 10 12 14 16 18 20
compilation info
Main.java:7: error: class Problem2 is public, should be declared in a file named Problem2.java
public class Problem2 {
       ^
1 error
stdout
Standard output is empty