Voici votre URL de partage https://sharemycode.io/c/f36deb4 (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 22 janv. 2025 à 23:16:54

Cet extrait expire le 21 févr. 2025 à 23:16:54

Langage : kotlin

Logo kotlin

Link

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

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