kotlin 判断数字_Kotlin程序检查数字是偶数还是奇数
生活随笔
收集整理的這篇文章主要介紹了
kotlin 判断数字_Kotlin程序检查数字是偶数还是奇数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
kotlin 判斷數字
Given a number N, we have to check whether it is EVEN or ODD.
給定數字N ,我們必須檢查它是偶數還是奇數 。
Example:
例:
Input:N = 13Output:"ODD"Input:N = 24Output:"EVEN"程序在Kotlin檢查偶數或奇數 (Program to check EVEN or ODD in Kotlin)
/* * Kotlin program to Input Integer * Numbers and check Number is Even or ODD */package com.includehelp.basicimport java.util.*// Main Method Entry Point of Program fun main(args: Array<String>) {// InputStream to get Inputval reader = Scanner(System.`in`)//Input Integer Valueprintln("Enter Integer Value : ")var number = reader.nextInt();val str = if(number%2==0) "EVEN" else "ODD"println("Number is $str") }Output
輸出量
RUN 1: Enter Integer Value : 34 Number is EVEN --- Run 2: Enter Integer Value : 15 Number is ODD翻譯自: https://www.includehelp.com/kotlin/check-whether-a-number-is-even-or-odd.aspx
kotlin 判斷數字
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的kotlin 判断数字_Kotlin程序检查数字是偶数还是奇数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 合肥治疗少精弱精最好的医院推荐
- 下一篇: 东星斑多少钱一斤啊?