Voici votre URL de partage https://sharemycode.io/c/01b0100 (Cliquer pour copier) (Copié)

Nom du fichier : Correction.kt

fun main() {

    fun additionCorrection1(a: Int, b: Int)
    = "$a + $b = ${a + b}"


    fun majorityCorrection2(nom:String, age:Int):String
    = "Bonjour $nom vous êtes ${if(age<18) "mineur" else "majeur"}"


    fun tableCorrection3(int: Int):List<String> {
        val listMultiplication = mutableListOf<String>()
        for ( i in 1 .. 10)
            listMultiplication.add("${int}*${i}= ${int * i}")
        return listMultiplication.toList()
    }



    fun intExercice4(first:Int, second:Int, third :Int):List<String> {
        val arrayInts = arrayOf(first, second, third)
        var displayTab = " "
        var heighestInt : Int = first
        var sum : Int = 0

        for (int in arrayInts){
            displayTab += "$int, "
            sum += int
            if (int>heighestInt)
                heighestInt = int
        }
            return  listOf(
                "Le tableau obtenu est : $displayTab",
                "La valeur moyenne est : ${sum.toDouble()/3})",
                "La valeur la plus grande est $heighestInt")
    }
}

fun mainPrincipal() {
    // listMultiplication
//    var listDisplay = " "
//    val l= tableCorrection(5)
//    for (line in tableCorrection(5))
//        listDisplay += line+"\n"
}

Informations

Cet extrait a été créé le 23 janv. 2025 à 22:12:17

Cet extrait expire le 22 févr. 2025 à 22:12:17

Langage : kotlin

Logo kotlin

Link

Voici votre URL de partage : https://sharemycode.io/c/01b0100 Copié

Ce code a été partagé avec Share on ShareMyCode.io pour Jetbrains