Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company
- import java.util.*
- fun main() {
- val sc = Scanner(System.`in`)
- val n = sc.nextInt()
- val list = ArrayList<Int>()
- for (i in 0 until n) {
- val num = sc.nextInt()
- list.add(num)
- }
- println(countOddDigitNumbers(list, n))
- }
- fun countOddDigitNumbers(list: ArrayList<Int>, n: Int): Int {
- var count = 0
- for (num in list) {
- if (hasOddDigits(num))
- count++
- }
- return count
- }
- fun hasOddDigits(n: Int): Boolean {
- var num = n
- var digits = 0
- while (num > 0) {
- digits++
- num /= 10
- }
- return digits % 2 == 1
- }
Add Comment
Please, Sign In to add comment