Write a C# Sharp program to find the larger from two given integers. However if the two integers have the same remainder when divided by 7, then the return the smaller integer. If the two integers are the same, return 0
- برمجة سي شارب
- برمجة
- 2021-05-16
- MarwaMohammed
الأجوبة
using System;
using System.Linq;
namespace exercises {
class Program {
static void Main(string[] args) {
Console.WriteLine(test(11, 21));
Console.WriteLine(test(11, 20));
Console.WriteLine(test(24, 10));
Console.WriteLine(test(10, 10));
Console.ReadLine();
}
public static int test(int x, int y) {
if (x == y) return 0;
if (x % 7 == y % 7) return (x < y) ? x: y;
return (x > y) ? x: y;
}
}
}
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال