F1-Aimport java util.* fun Digit (a: Char): Boolean {


Download 16.05 Kb.
Sana10.05.2020
Hajmi16.05 Kb.
#104581
Bog'liq
Funkciya


F1-A

import java.util.*


fun Digit (a: Char): Boolean {
var res = false
if (a.isDigit()) {
res = true
}
return res
}

fun main(args: Array) {


val input = Scanner(System.`in`)
var n = input.nextInt()
var sum = 0
for (i in 0 until n) {
var m: Char = input.next().single()
if (Digit(m)) {
sum++
}
}
println(sum)
}

F1-B


import java.util.*
fun Letter (b: Char): Boolean {
var res = false
if (b.toString() in "a".."z") {
res = true
}
return res
}

fun main () {


val input = Scanner(System.`in`)
var n = input.nextInt()
var juwap = 0
for (i in 0 until n) {
var x : Char = input.next().single()
if (Letter(x)) {
juwap++
}
}
println(juwap)
}

F1-C


import java.util.*
fun Faktorial(n: Int): Int {

var res = 1


for (i in 1 .. n){
res *= i
}
return res
}

fun main() {


val input = Scanner(System.`in`)
var m = input.nextInt()
var k = input.nextInt()
var fak = Faktorial(m) / (Faktorial(k) * Faktorial(m-k))
println(fak)
}

F1-D


import java.util.*

fun Prime(num: Int) : Boolean {


var res = true
for (i in 2 until num) {
if (num % i == 0) {
res = false
}
}
return res
}

fun main() {


val input = Scanner(System.`in`)
var n = input.nextInt()
var sum = 0
for (i in 1..n) {
val x = input.nextInt()
if (Prime(x)) sum += x
}
println(sum)
if (Prime(sum)) println("YES")
else println("NO")
}
a

F1-E
Download 16.05 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling