val gameChose = getGameChose(options)
val userChoice = getUserChose(options)
getResult(gameChose, userChoice)
println("Do you want to play any more?")
playGameAnswer = readLine()
println("Oh..so sad. So, goodbye")
break
<fragment
android:id="@+id/fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
fab:defaultNavHost="false"
fab:navGraph="@navigation/nav_graph" />
open class MainActivity : AppCompatActivity() {
private lateinit var navController:NavController
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
//creating backArrow
navController=Navigation.findNavController(this,R.id.fragment)
NavigationUI.setupActionBarWithNavController(this,navController)
}
override fun onSupportNavigateUp(): Boolean {
return navController.navigateUp()
}
val fr = FileReader("f.txt")
val array=fr.readText()
.substringAfter(':')
.substringBefore('К')
.split(' ')
.toList()
.filter { !it.contains('0') && !it.contains('-') }
println(array)
fr.close()
val newFw = FileWriter("g4.txt")
var numbers = ""
numbers = array.toString()
.substringAfter('[')
.substringBefore("]")
.filter { !it.isWhitespace() && !it.equals(',') }
newFw.append(numbers)
newFw.close()
fun main() {
val fileName = "f18.txt"
val file = File(fileName)
val fw =FileWriter(file,true)
println("Введите диапазон A: ")
val a = readLine()!!.toInt()
println("Введите диапазон B: ")
val b = readLine()!!.toInt()
if ( a < b )
{
var positive = 0
var negative = 0
println("Введите количество чисел: ")
val count = readLine()!!.toInt()
val massive = IntArray(count)
fw.appendln("Исходный массив:")
fw.flush()
for ( i in 0 until count )
{
massive[i] = (a..b).random()
fw.appendln("${massive[i]} ")
when
{
massive[i] > 0 -> positive++
massive[i] < 0 -> negative++
}
}
fw.appendln("Количество положительных: $positive")
fw.flush()
fw.appendln("Количество отрицательных: $negative")
fw.flush()
when
{
positive > negative -> fw.appendln("В массиве положительных чисел больше отрицательных")
positive < negative -> fw.appendln("В массиве отрицательных чисел больше положительных")
positive == negative -> fw.appendln("В массиве одинаковое количество положительных и отрицательных чисел")
}
fw.flush()
}
else println("Введен не правильный диапазон.")
fw.close()
}
val scope1 = CoroutineScope(CoroutineName("MyCoroutine")+Dispatchers.IO)