Write a C# Sharp program to check if two or more non-negative given integers have the same rightmost digit

  • برمجة سي شارب
  • برمجة

Write a C# Sharp program to check if two or more non-negative given integers have the same rightmost digit

Sample Output:

True
True
False

الأجوبة

using System;
using System.Linq;
namespace exercises
{
   class Program
    {       
        static void Main(string[] args)
        {
            Console.WriteLine(test(11, 21, 31));
            Console.WriteLine(test(11, 22, 31));
            Console.WriteLine(test(11, 22, 33));
            Console.ReadLine();
        }
        public static bool test(int x, int y, int z)
        {
           return x % 10 == y % 10 || x % 10 == z % 10 || y % 10 == z % 10;
        }
    }
}
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...