Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ConsoleApp1
- {
- class Program
- {
- static string excludeEachNSymbol(string line, int N)
- {
- string cutLine = string.Empty;
- for (int i = 0; i < line.Length; i++)
- if ((i + 1) % N != 0)
- cutLine += line[i];
- return cutLine;
- }
- static void Main(string[] args)
- {
- Console.Write("Enter a line: ");
- string line = Console.ReadLine();
- if (line.Length % 2 == 0)
- Console.Write(excludeEachNSymbol(line, 2));
- else
- Console.Write("The string is of odd length.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement