Venciity

[Jumpstart C#] Exam - 5 задача

Feb 8th, 2014
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.71 KB | None | 0 0
  1. // http://jumpstart.bg/csharp/csharpexam1.html#/4
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace exercise5
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             Console.Write("x = ");
  15.             int x = Int32.Parse(Console.ReadLine());
  16.  
  17.             Console.Write("y = ");
  18.             int y = Int32.Parse(Console.ReadLine());
  19.  
  20.             int originX = 10;
  21.             int originY = 5;
  22.  
  23.             int transformedX = originX + x;
  24.             int transformedY = originY - y;
  25.  
  26.             for (int row = 0; row < 11; row++)
  27.             {
  28.                 for (int column = 0; column < 21; column++)
  29.                 {
  30.                     if (transformedX == column && transformedY == row)
  31.                     {
  32.                         Console.Write("*");
  33.                     }
  34.                     else if (row == 5)
  35.                     {
  36.                         if (column == 10)
  37.                         {
  38.                             Console.Write("+");
  39.                         }
  40.                         else
  41.                         {
  42.                             Console.Write("-");
  43.                         }
  44.                     }
  45.                     else
  46.                     {
  47.                         if (column == 10)
  48.                         {
  49.                             Console.Write("|");
  50.                         }
  51.                         else
  52.                         {
  53.                             Console.Write(" ");
  54.                         }
  55.                     }
  56.                 }
  57.                 Console.WriteLine();
  58.             }
  59.  
  60.             if (x > 0)
  61.             {
  62.                 if (y > 0)
  63.                 {
  64.                     Console.WriteLine("1");
  65.                 }
  66.                 else if (y < 0)
  67.                 {
  68.                     Console.WriteLine("4");
  69.                 }
  70.                 else
  71.                 {
  72.                     Console.WriteLine("x");
  73.                 }
  74.             }
  75.             else if (x < 0)
  76.             {
  77.                 if (y > 0)
  78.                 {
  79.                     Console.WriteLine("2");
  80.                 }
  81.                 else if (y < 0)
  82.                 {
  83.                     Console.WriteLine("3");
  84.                 }
  85.                 else
  86.                 {
  87.                     Console.WriteLine("x");
  88.                 }
  89.             }
  90.             else
  91.             {
  92.                 if (y == 0)
  93.                 {
  94.                     Console.WriteLine("+");
  95.                 }
  96.                 else
  97.                 {
  98.                     Console.WriteLine("y");
  99.                 }
  100.             }
  101.         }
  102.     }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment