hamzajaved

Enter the string of odd numbers

Dec 11th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace string_of_odd_numbers
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string s;
  14.             char[,] box;
  15.             Console.WriteLine("Enter the string of odd Numbers");
  16.             s = Console.ReadLine();
  17.             int length = s.Length;
  18.             int central = length / 2;
  19.             box = new char[length, length];
  20.  
  21.             for (int i = 0; i < s.Length; i++)
  22.             {
  23.                 for (int j = 0; j < s.Length; j++)
  24.                 {
  25.                     if(i == central)
  26.                     {
  27.                         box[i, j] = s[j];
  28.                     }
  29.                     if(j == central)
  30.                     {
  31.                         box[i, j] = s[i];
  32.                     }
  33.                     if(i!=central && j !=central)
  34.                     {
  35.                         box[i, j] = 'X';
  36.                     }
  37.                 }
  38.             }
  39.  
  40.             for (int l = 0; l < s.Length; l++)
  41.             {
  42.                 for (int m = 0; m < s.Length; m++)
  43.                 {
  44.                     Console.Write(box[l,m]);
  45.                 }
  46.                 Console.WriteLine();
  47.             }
  48.  
  49.         }
  50.     }
  51. }
Add Comment
Please, Sign In to add comment