Write a Scala program to check the largest number among three given integers

  • برمجة سكالا

Write a Scala program to check the largest number among three given integers.

الأجوبة

object scala_basic {
  def test(x: Int, y: Int, z: Int): Int = {
       List(x, y, z).max
    }
     
   def main(args: Array[String]): Unit = {
      println("Result: " + test(1,2,3));
      println("Result: " + test(1,3,2));
      println("Result: " + test(1,1,1));
      println("Result: " + test(1,2,2));
    }
  }

Sample Output:

Result: 3
Result: 3
Result: 1
Result: 2
هل كان المحتوى مفيد؟

معلومات ذات صلة

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

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