Advertisement
Myknakryu

Algorytm5 Java interrupt

Sep 19th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. class algorytm5
  2. {
  3. public static void main(String[] args)
  4. {
  5. int i, a, x, suma;
  6.  
  7. i = 0;
  8. a = 2;
  9. x = 4;
  10. suma = 0;
  11.  
  12. System.out.println();
  13. // Wypisuje startowe wartości
  14. System.out.println("i = " + i);
  15. System.out.println("a = " + a);
  16. System.out.println("x= " + x);
  17. System.out.println("suma = " + suma);
  18.  
  19. System.out.println();
  20.  
  21. petla:
  22.  
  23. for(i = 0; i < 4;)
  24. {
  25. System.out.println();
  26.  
  27. // Wypisuje startowe wartości
  28. System.out.print(i + " < 4: ");
  29. System.out.println( i < 4);
  30.  
  31. System.out.println("Przebieg pętli: " + i);
  32.  
  33. //i:=i+1
  34. System.out.print( + i +" + 1 = ");
  35. i = i + 1;
  36. System.out.println(i);
  37.  
  38. if(!(i < 4))
  39. {
  40. System.out.println("Wybijam z pętli!");
  41. break petla;
  42. }
  43.  
  44. //suma:=suma+a
  45. System.out.print( a + " + " + suma + " = ");
  46. suma = suma + a;
  47. System.out.println(suma);
  48.  
  49. //a:=a+x
  50. System.out.print(a + " + " + x + " = ");
  51. a = a + x;
  52. System.out.println(a);
  53.  
  54. }
  55. System.out.println();
  56.  
  57. //Wyświetla boolowską reprezentację i < 4
  58. System.out.print(i + " < 4: ");
  59. System.out.println( i < 4);
  60.  
  61. //wypisz: suma
  62. System.out.println(suma);
  63.  
  64. System.out.println();
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement