学习一下kotlin的语法
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param n int整型 * @return int整型 */ fun NumberOf1Between1AndN_Solution(n: Int): Int { // write code here var count = 0 var left = n/10 var right = 0 var dig = 1 var cur = n % 10 while(cur !=0 || left != 0 ) { count += if(cur == 0) left * dig else if(cur == 1) left * dig + right + 1 else left * dig + dig right = right + dig * cur dig *= 10 cur = left % 10 left = left / 10 } return count } }