svetlozar_kirkov

Car

Sep 18th, 2014
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.19 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Car
  4. {
  5.     class Car
  6.     {
  7.         static void Main()
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             int width = 3 * n;
  11.             int height = 3 * (n / 2) - 1;
  12.             int roofBodyHeight = n / 2;
  13.             int wheelsHeight = (n / 2) - 1;
  14.  
  15.             for (int i = 1; i <= height+1; i++)
  16.             {
  17.                 if (i == 1)
  18.                 {
  19.                     Console.Write(new string('.', width - 2 * n));
  20.                     Console.Write(new string('*', n));
  21.                     Console.Write(new string('.', width - 2 * n));
  22.                     Console.WriteLine();
  23.                 }
  24.                 else if (i > 1 && i <= roofBodyHeight)
  25.                 {
  26.                     for (int j = 1, k = (width - 2 * n) - 1, m = n; j < roofBodyHeight ; j++, k--, m+=2)
  27.                     {
  28.                         Console.Write(new string('.', k));
  29.                         Console.Write(new string('*', 1));
  30.                         Console.Write(new string('.', m));
  31.                         Console.Write(new string('*', 1));
  32.                         Console.Write(new string('.', k));
  33.                         Console.WriteLine();
  34.                         i++;
  35.                     }
  36.                 }
  37.                 else if (i == roofBodyHeight+2)
  38.                 {
  39.                     Console.Write(new string('*', i-1));
  40.                     Console.Write(new string('.', (width - 2 * i)+2));
  41.                     Console.Write(new string('*', i-1));
  42.                     Console.WriteLine();
  43.                 }
  44.                 else if (i > roofBodyHeight+2 && i < roofBodyHeight*2+1)
  45.                 {
  46.                     Console.Write(new string('*', 1));
  47.                     Console.Write(new string('.', width - 2));
  48.                     Console.Write(new string('*', 1));
  49.                     Console.WriteLine();
  50.                 }
  51.                 else if (i == roofBodyHeight*2+1)
  52.                 {
  53.                     Console.WriteLine(new string('*', width));
  54.                 }
  55.                 else if (i > roofBodyHeight*2+1 && i < height+1)
  56.                 {
  57.                     Console.Write(new string('.', n / 2));
  58.                     Console.Write(new string('*', 1));
  59.                     Console.Write(new string('.', (n / 2) - 1));
  60.                     Console.Write(new string('*', 1));
  61.                     Console.Write(new string('.', n - 2));
  62.                     Console.Write(new string('*', 1));
  63.                     Console.Write(new string('.', (n / 2) - 1));
  64.                     Console.Write(new string('*', 1));
  65.                     Console.Write(new string('.', n / 2));
  66.                     Console.WriteLine();
  67.                 }
  68.                 else if (i == height+1)
  69.                 {
  70.                     Console.Write(new string('.', n/2));
  71.                     Console.Write(new string('*', n / 2 + 1));
  72.                     Console.Write(new string('.', width - ((2*(n/2)+1)+2*(n/2))-1));
  73.                     Console.Write(new string('*', n / 2 + 1));
  74.                     Console.Write(new string('.', n/2));
  75.                     Console.WriteLine();
  76.                 }
  77.             }
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment