Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace _02._Activation_Keys
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- string[] inputAsArray = input.Split("&");
- List<string> keys = new List<string>();
- for (int i = 0; i < inputAsArray.Length; i++)
- {
- bool isValdKey = true;
- if (inputAsArray[i].Length == 16 || inputAsArray[i].Length == 25)
- {
- for (int j = 0; j < inputAsArray[i].Length; j++)
- {
- if (!char.IsLetterOrDigit(inputAsArray[i][j]))
- {
- isValdKey = false;
- }
- }
- if (isValdKey)
- {
- keys.Add(inputAsArray[i].ToUpper());
- }
- }
- }
- for (int i = 0; i < keys.Count; i++)
- {
- if (keys[i].Length == 16)
- {
- string temp = string.Empty;
- for (int j = 0; j < keys[i].Length; j++)
- {
- temp += keys[i][j];
- if ((j + 1) % 4 == 0 && j != 15)
- {
- temp += "-";
- }
- }
- keys[i] = temp;
- }
- else if (keys[i].Length == 25)
- {
- string temp = string.Empty;
- for (int j = 0; j < keys[i].Length; j++)
- {
- temp += keys[i][j];
- if ((j + 1) % 5 == 0 && j != 24)
- {
- temp += "-";
- }
- }
- keys[i] = temp;
- }
- }
- for (int i = 0; i < keys.Count; i++)
- {
- string temp = string.Empty;
- for (int j = 0; j < keys[i].Length; j++)
- {
- if (char.IsDigit(keys[i][j]))
- {
- int num = (9 - int.Parse(keys[i][j].ToString()));
- temp = string.Concat(temp, num);
- }
- else
- {
- temp += keys[i][j];
- }
- }
- keys[i] = temp;
- }
- Console.WriteLine(string.Join(", ", keys));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement