Write a Scala program to check whether two given positive integers have the same last digit
- برمجة سكالا
- 2021-09-23
- mhanasmh00489829403
الأجوبة
object scala_basic {
def test(x: Int, y: Int): Boolean = {
Math.abs(x % 10) == Math.abs(y % 10);
}
def main(args: Array[String]): Unit = {
println("Result: " + test(123, 456));
println("Result: " + test(12, 512));
println("Result: " + test(7, 87));
println("Result: " + test(12, 45));
}
}
Sample Output:
Result: false Result: true Result: true Result: false
القوائم الدراسية التي ينتمي لها السؤال
معلومات ذات صلة