Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4.  
  5. public class example {
  6. public static void main(String[] args) throws IOException {
  7. BufferedReader reader =
  8. new BufferedReader(new InputStreamReader(System.in));
  9.  
  10. char lastSector = reader.readLine().charAt(0);
  11. int firstSectorRows = (Integer.parseInt(reader.readLine()));
  12. int placesInOddRow = (Integer.parseInt(reader.readLine()));
  13. int placesInEvenRow = placesInOddRow+2;
  14. int allPlace =0;
  15.  
  16. for (int i = 65; i <= lastSector ; i++) {
  17. for (int j = 1; j <=firstSectorRows ; j++) {
  18.  
  19.  
  20. if (j%2==0){
  21. for (int k = 97; k < 97 + placesInEvenRow; k++) {
  22. char sector = (char)i;
  23. int row = j;
  24. char place = (char)k;
  25. String stringForOutPut = String.format("%s%d%s",sector,row,place);
  26. System.out.println(stringForOutPut);
  27. allPlace++;
  28. }
  29. }else {
  30. for (int k = 97; k < 97 + placesInOddRow; k++) {
  31.  
  32. char sector = (char)i;
  33. int row = j;
  34. char place = (char)k;
  35. String stringForOutPut = String.format("%s%d%s",sector,row,place);
  36. System.out.println(stringForOutPut);
  37. allPlace++;
  38. }
  39. }
  40. }
  41. firstSectorRows++;
  42.  
  43. }
  44. System.out.println(allPlace);
  45.  
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement