Advertisement
Valleri

C# Basics Exam 25 July 2014 Morning - 03. Panda Scotland Fla

Aug 1st, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class ScotlandPanda {
  5.     private static char returnCode(int a) {
  6.         if (a % 26 == 0) {
  7.             a = 26;
  8.         }
  9.         if (a > 26) {
  10.             a = a % 26;
  11.         }
  12.         return (char) (64 + a);
  13.     }
  14.     public static void main(String[] args) {
  15.         @SuppressWarnings("resource")
  16.         Scanner input = new Scanner(System.in);
  17.        
  18.         int n = input.nextInt();
  19.         int alfa = 1;
  20.         for (int i = 0; i < n/2; i++) {
  21.             System.out.printf("%s%s%s%s%s\n", new String(new char[i]).replace('\0', '~'),
  22.                     returnCode(alfa),
  23.                     new String(new char[n-2 - (2*i)]).replace('\0', '#'),
  24.                     returnCode(alfa+1),
  25.                     new String(new char[i]).replace('\0', '~'));
  26.             alfa+=2;
  27.         }
  28.  
  29.         System.out.printf("%1$s%2$s%1$s\n", new String(new char[n/2]).replace('\0', '-'),
  30.                                             returnCode(alfa));
  31.         alfa++;
  32.        
  33.         for (int i = n/2 - 1; i >= 0; i--) {
  34.             System.out.printf("%s%s%s%s%s\n", new String(new char[i]).replace('\0', '~'),
  35.                     returnCode(alfa),
  36.                     new String(new char[n-2 - (2*i)]).replace('\0', '#'),
  37.                     returnCode(alfa+1),
  38.                     new String(new char[i]).replace('\0', '~'));
  39.             alfa+=2;
  40.         }
  41.  
  42.     }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement