kotlin 判断数字_Kotlin程序检查数字是偶数还是奇数
生活随笔
收集整理的這篇文章主要介紹了
kotlin 判断数字_Kotlin程序检查数字是偶数还是奇数
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
kotlin 判斷數(shù)字
Given a number N, we have to check whether it is EVEN or ODD.
給定數(shù)字N ,我們必須檢查它是偶數(shù)還是奇數(shù) 。
Example:
例:
Input:N = 13Output:"ODD"Input:N = 24Output:"EVEN"程序在Kotlin檢查偶數(shù)或奇數(shù) (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 判斷數(shù)字
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的kotlin 判断数字_Kotlin程序检查数字是偶数还是奇数的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 合肥治疗少精弱精最好的医院推荐
- 下一篇: c语言指针++_C ++此指针| 查找输