Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace LettersCombinations
- {
- class LettersCombinations
- {
- static void Main()
- {
- char n1 = Convert.ToChar(Console.ReadLine()); // Start letter
- char n2 = Convert.ToChar(Console.ReadLine()); // End letter
- char n3 = Convert.ToChar(Console.ReadLine()); // Letter to skip
- int start = 0;
- int end = 0;
- long counter = 0;
- char[] charArray = "abcdefghijklmnopqrstuvwxyz".ToCharArray(); // Assigning a-z array
- for (int i = 0; i < charArray.Length - 1; i++) // Loop for gathering index of the start/end letters
- {
- if (charArray[i] == n1) // Gathering start letter index
- {
- start = i;
- }
- if (charArray[i] == n2) // Gathering end letter index
- {
- end = i;
- }
- if (end != 0) // Breaking the loop if end letter index is gathered
- {
- break;
- }
- }
- for (int i = start; i <= end; i++) // Combinations printing loop 1
- {
- if (charArray[i] == n3) // Skipping the combination containing n3
- {
- continue;
- }
- for (int j = start; j <= end; j++) // Combinations printing loop 1.1
- {
- if (charArray[j] == n3) // Skipping the combination containing n3
- {
- continue;
- }
- for (int k = start; k <= end; k++) // Combinations printing loop 1.2
- {
- if (charArray[k] == n3) // Skipping the combination containing n3
- {
- continue;
- }
- Console.Write("{0}{1}{2} ", charArray[i], charArray[j], charArray[k]);
- counter++;
- }
- }
- }
- Console.Write(counter);
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement