Chessmaster

Untitled

Jun 13th, 2018
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using System;
  2.  
  3. namespace StringConcatenation
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             char delimeter = char.Parse(Console.ReadLine());
  10.             string evenOrOdd = Console.ReadLine();
  11.             int n = int.Parse(Console.ReadLine());
  12.  
  13.             string sentence = null;
  14.  
  15.             for (int i = 1; i <= n; i++)
  16.             {
  17.                 string word = Console.ReadLine();
  18.  
  19.                 if (evenOrOdd == "odd")
  20.                 {
  21.                     if (i % 2 != 0)
  22.                     {
  23.                         sentence = sentence + word + delimeter;
  24.                     }
  25.                 }
  26.                 else
  27.                 {
  28.                     if (i % 2 == 0)
  29.                     {
  30.                         sentence = sentence + word + delimeter;
  31.                     }
  32.                 }
  33.             }
  34.  
  35.             if (sentence.EndsWith(delimeter))
  36.             {
  37.               sentence = sentence.Remove(sentence.Length - 1);
  38.                 Console.WriteLine(sentence);
  39.             }
  40.             else
  41.             {
  42.                 Console.WriteLine(sentence);
  43.             }
  44.         }
  45.     }  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment