Add a beautiful code :)
This commit is contained in:
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -1,7 +1,39 @@
|
|||||||
fun main(args: Array<String>) {
|
|
||||||
println("Hello World!")
|
|
||||||
|
|
||||||
// Try adding program arguments via Run/Debug configuration.
|
fun main() {
|
||||||
// Learn more about running applications: https://www.jetbrains.com/help/idea/running-applications.html.
|
var x: Int? = null;
|
||||||
println("Program arguments: ${args.joinToString()}")
|
var y: Int? = null;
|
||||||
|
var min: Int? = null;
|
||||||
|
var max: Int? = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
print("X = ");
|
||||||
|
x = readLine()?.toInt()
|
||||||
|
|
||||||
|
print("Y = ");
|
||||||
|
y = readLine()?.toInt()
|
||||||
|
|
||||||
|
print("Min = ");
|
||||||
|
min = readLine()?.toInt()
|
||||||
|
|
||||||
|
print("Max = ");
|
||||||
|
max = readLine()?.toInt()
|
||||||
|
} catch (_: NumberFormatException) {}
|
||||||
|
|
||||||
|
|
||||||
|
if(x != null && y != null && max != null && min != null && min <= max) {
|
||||||
|
val strings = List(max - min) { // Creo la lista utilizzando lambda expression
|
||||||
|
val n = it+min // it rappresenta l'indice della lista che sto inizializzando, il numero corrispondente è quindi it+min
|
||||||
|
if(n % x == 0) {
|
||||||
|
"Cip"
|
||||||
|
} else if(n % y == 0) {
|
||||||
|
"Ciop"
|
||||||
|
} else {
|
||||||
|
n
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
println(strings)
|
||||||
|
} else {
|
||||||
|
println("Input non valido")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user