Advertisement
mustafov

Cube

Sep 3rd, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.14 KB | None | 0 0
  1. // Cube
  2. //Ivcho is a big computer genius. One day he was bored from all the girls that wanted to be with him and instead decided to wright //a computer game. Because he always likes to do things the hard way he decided to make a console game, but not any console game – //a 3D one! Just for the fun of it. But because he isn’t very good with graphics he needs your help with the basic building blocks //witch he can feed to his magic algorithm that produces HD 3D-reality in the console.
  3. //Your task is to wright a program that supplies him with cubes (basic building blocks). He will give you a number N and you should //print a cube with width = height = depth = N as shown in the examples. Mark the sides with “:” (colon).
  4. //In addition you will have to fill in some of the sides of the cube:
  5. //•   The top should be filled in with “/” (slash)
  6. //•   The side should be filled in with “X” (capital letter X)
  7.  
  8.  
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14.  
  15. namespace ConsoleApplication5
  16. {
  17.     class Program
  18.     {
  19.         static void Main(string[] args)
  20.         {
  21.             int n = int.Parse(Console.ReadLine());
  22.             string blank = new string(' ', n - 1);
  23.             string dots = new string(':', n);
  24.             Console.WriteLine("{0}{1}",blank,dots);
  25.             for (int i = 0; i < n - 2; i++)
  26.             {
  27.                 string slashes = new string ('/', n - 2);
  28.                 string blankk = new string (' ',2 * n - (n - 2) - i - 4);
  29.                 string xxx = new string('X',i);
  30.                 Console.WriteLine("{0}:{1}:{2}:",blankk,slashes,xxx);
  31.             }
  32.             string dotss = new string(':', n);
  33.             string xx = new string('X', n - 2);
  34.             Console.WriteLine("{0}{1}:",dotss,xx);
  35.             for (int i = n - 3; i >= 0; i--)
  36.             {
  37.                 string xxxx = new string ('X',i);
  38.                 string b = new string(' ', n - 2);
  39.                 Console.WriteLine(":{0}:{1}:",b,xxxx);
  40.             }
  41.             string d = new string(':', n);
  42.             Console.WriteLine("{0}",d);
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement