Write a C# Sharp program to combine two given strings (lowercase). If there are any double character in new string then omit one character
- برمجة سي شارب
- برمجة
- 2021-05-17
- MarwaMohammed
الأجوبة
using System;
namespace exercises
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(test("abc", "cat"));
Console.WriteLine(test("python", "php"));
Console.WriteLine(test("php", "php"));
Console.ReadLine();
}
public static string test(string s1, string s2)
{
if (s1.Length < 1)
{
return s2;
}
if (s2.Length < 1)
{
return s1;
}
return !s1.EndsWith(s2.Substring(0, 1)) ? s1 + s2 : s1 + s2.Substring(1);
}
}
}أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
