Advertisement
Guest User

Untitled

a guest
Nov 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. public
  2. class ppj14{
  3. public static void main(String[]args){
  4. int rozm=5;
  5. char znak='o';
  6.  
  7. ppj14.kwadrat(rozm,znak);
  8.  
  9. }
  10.  
  11.  
  12. static void kwadrat(int rozm, char znak){
  13. char[][] newarray= new char[rozm][rozm];
  14. int OczyZ=0;
  15. for(int i=0; i<rozm; i++){
  16. for(int j=0; j<rozm;j++){
  17. if(znak=='o'){
  18. if(OczyZ%2==0){
  19. newarray[i][j]='o';
  20. OczyZ++;
  21. }
  22. else if(OczyZ%2==1){
  23. newarray[i][j]='z';
  24. OczyZ++;
  25. }
  26. }
  27. else if(znak=='z'){
  28. if(OczyZ%2==0){
  29. newarray[i][j]='o';
  30. OczyZ++;
  31. }
  32. else if(OczyZ%2==1){
  33. newarray[i][j]='z';
  34. OczyZ++;
  35. }
  36. }
  37. }
  38. }
  39. for(int i=0; i<rozm; i++){
  40. for(int j=0; j<rozm; j++){
  41. System.out.print(newarray[i][j]);
  42. }
  43. System.out.println();
  44. }
  45.  
  46.  
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement