Advertisement
BojidarDosev

Да се състави програма на C++, чрез която от клавиатурата се въвеждат последователно две редици от символи (стринг-низ) без интервали. Всяка от тях е с дължина от интервала [5..55] символа. Програмата да извежда съобщение за резултата от сравнението им по

Nov 22nd, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 KB | None | 0 0
  1. string a = Console.ReadLine();
  2.                 string b = Console.ReadLine();
  3.                 int bra = a.Length;
  4.                 int brb = b.Length;
  5.                 if (bra == brb)
  6.                     Console.WriteLine("двата низа са с еднаква дължина");
  7.                 else
  8.                     Console.WriteLine("двата низа не са с еднаква дължина");
  9.                 if(bra == brb)
  10.                 {
  11.                     for (int i = 0; i < a.Length; i++)
  12.                     {
  13.                         if (a[i] != b[i])
  14.                         {
  15.                             Console.WriteLine((i + 1) + " " + a[i] + "-" + b[i]);
  16.                         }
  17.                     }
  18.                 }
  19.                 else
  20.                 {
  21.                     if (bra > brb)
  22.                     {
  23.                         for (int i = 0; i < b.Length; i++)
  24.                         {
  25.                           if (a[i] != b[i])
  26.                           {
  27.                             Console.WriteLine((i + 1) + " " + a[i] + "-" + b[i]);
  28.                           }
  29.                         }
  30.                         Console.WriteLine(a.Remove(0,b.Length));
  31.                     }
  32.                     else
  33.                     {
  34.                         for (int i = 0; i < a.Length; i++)
  35.                         {
  36.                             if(a[i] != b[i])
  37.                             {
  38.                                 Console.WriteLine((i + 1) + " " + a[i] + "-" + b[i]);
  39.                             }
  40.                         }
  41.                         Console.WriteLine(b.Remove(0, a.Length));
  42.                     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement