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 Laba5zad6
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Введите длину строки с алфавитом 'abcdefgh1234567?!;': ");
- int lengthOfSymbols = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Строка:");
- const string symbols = "abcdefgh1234567?!;";
- var rand = new Random();
- StringBuilder text = new StringBuilder() { Length = lengthOfSymbols };
- for (int i = 0; i < text.Length; i++)
- {
- int index = rand.Next(symbols.Length);
- text[i] = symbols[index];
- }
- Console.WriteLine(text + "\n");
- for (int i = 0; i < text.Length; i++)
- {
- if (text[i] == ';')
- {
- text[i] = '_';
- }
- }
- Console.WriteLine("Строка с заменой ';' на '_':");
- Console.WriteLine(text);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement