Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _14.MagicLetter
- {
- class Program
- {
- static void Main(string[] args)
- {
- //Write a program, which prints all 3-letter combinations, using only the letters from a given interval.
- //You will also receive a third letter. Every combination, which contains this letter should not be printed.
- //Examples:
- //input : a c b
- //output: aaa aac aca acc caa cac cca ccc
- char letter1 = char.Parse(Console.ReadLine());
- char letter2 = char.Parse(Console.ReadLine());
- //letter3 is the letter which shouldn't be printed if the sequence contains it.
- char letter3 = char.Parse(Console.ReadLine());
- //letter3 to string, so I can use the .contains method at the end.
- string forbiddenLetter = letter3.ToString();
- for (char i = letter1; i <= letter2; i++)
- {
- for (char j = letter1; j <= letter2; j++)
- {
- for (char l = letter1; l <= letter2; l++)
- {
- //the fore-mentioned sequence of letters to be printed.
- string sequence = $"{i}{j}{l}";
- if (sequence.Contains(forbiddenLetter))
- {
- }
- else
- {
- Console.Write(sequence + " ");
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement