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. {
  13. int c= 1;
  14. int v = 0;
  15. for (int z = 1 ;z<=5;z++)
  16. {
  17. if (z%2==1)
  18. {
  19. for(int y = 1;y<=z;y++)
  20. {
  21. System.out.print(c);
  22.  
  23. if(y==z)
  24. {
  25. System.out.println();
  26. c=1;
  27. break;
  28. }
  29.  
  30. else{
  31. if(c==1)
  32. c = 0;
  33. else
  34. c=1;
  35. }
  36. }
  37. }
  38.  
  39. else
  40. {
  41. for(int l = 1;l<=z;l++)
  42. {
  43. System.out.print(v);
  44. if(l==z)
  45. {
  46. System.out.println();
  47. v=0;
  48. break;
  49. }
  50. else
  51. {
  52. if(v ==0)
  53. v = 1;
  54. else
  55. v=0;
  56. }
  57.  
  58. }
  59.  
  60.  
  61. }
  62. }
  63. }
  64. }
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
Success #stdin #stdout 0.06s 51120KB
stdin
Standard input is empty
stdout
1
01
101
0101
10101