fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. d(new int[]{1});System.out.println();
  13. d(new int[]{5,0,5});System.out.println();
  14. d(new int[]{3,2,1});System.out.println();
  15. d(new int[]{0,9,3});System.out.println();
  16. d(new int[]{1,2,3,4});System.out.println();
  17. d(new int[]{4,1,2,3});System.out.println();
  18. d(new int[]{0,2,0,2});System.out.println();
  19. d(new int[]{5,3,9,2,6,7});System.out.println();
  20. d(new int[]{0,0,0,0,0,0,0});System.out.println();
  21. d(new int[]{75,230,30,42,50});System.out.println();
  22. d(new int[]{255,255,200,200,203});System.out.println();
  23. }
  24.  
  25. static void d(int[]a){
  26. String s="";
  27. for(int v,w,x=-1,y,z=a.length;++x<z;){
  28. v=a[x];
  29. s=""+v;
  30. for(y=0;++y<z;v=w){
  31. w=a[(y+x)%z];
  32. if(v>w){
  33. s="f";
  34. break;
  35. }
  36. s+=" "+w;
  37. }
  38. if(y==z)break;
  39. }
  40. System.out.print(s);
  41. }
  42.  
  43. }
Success #stdin #stdout 0.11s 321600KB
stdin
Standard input is empty
stdout
1
0 5 5
f
f
1 2 3 4
1 2 3 4
f
f
0 0 0 0 0 0 0
30 42 50 75 230
200 200 203 255 255