Bloknot dasturi automatic ochiladi




Download 1,4 Mb.
Sana15.05.2024
Hajmi1,4 Mb.
#235943
Bog'liq
Raimjonov Muhammadali 3- dedline





Script kodi

Izoh

screenshot

1

Notepad

Bloknot dasturi automatic ochiladi



2

$wordApp = New-Object -ComObject Word.Application
$wordApp.Visible = $true



Word dasturi automatic ochiladi



3

$randomNumber = Get-Random -Minimum 1 -Maximum 101
$guess = -1

Write-Host "Men 1 dan 100 gacha son o'yladim. Topa olasizmi?"


while ($guess -ne $randomNumber) {


$guess = Read-Host "Son kiriting:"
if ($guess -lt $randomNumber) {
Write-Host "Katta son kiriting"
} elseif ($guess -gt $randomNumber) {
Write-Host "Kichik son kiriting"
}
}

Write-Host "Tabriklaymiz! To'g'ri topdingiz. Son: $randomNumber"



KOmpyuter son o’yladi menga uni toppish vazifasi yuklandi



4

$randomNumber = Get-Random -Minimum 1 -Maximum 101
$guess = -1

Write-Host "Men 1 dan 100 gacha son o'yladim. Topa olasizmi?"


while ($guess -ne $randomNumber) {


$guess = Read-Host "Son kiriting:"
if ($guess -lt $randomNumber) {
Write-Host "Katta son kiriting"
} elseif ($guess -gt $randomNumber) {
Write-Host "Kichik son kiriting"
}
}

Write-Host "Tabriklaymiz! To'g'ri topdingiz. Son: $randomNumber"



KOmpyuter son o’yladi menga uni toppish vazifasi yuklandi



5

$number = 5
$square = $number * $number
Write-Host "Son: $number ning kvadrati: $square"

Berilgan sonni kvadratini hisoblaydi



6

# Funksiya: Ildizni topish
Function IldizTopish($son) {
$ildiz = [math]::sqrt($son)
Write-Host "Ildiz: $ildiz"
}

# Funksiya: Son kiritish


Function SonKiritish {
$son = Read-Host "Iltimos, biror son kiriting:"
return $son
}

# O'yin boshlandi


Function Boshlash {
Write-Host "Ildiz Topish o'yini boshlandi!"
}

# Dastur ishga tushirish


Boshlash

do {
$kirilganSon = SonKiritish


IldizTopish $kirilganSon

$yangiSonKiritish = Read-Host "Yana bir son kiritasizmi? (ha/yo'q)"


if ($yangiSonKiritish -ne 'ha') {
Write-Host "O'yin uchun rahmat!"
break
}
} while ($true)

Sonni ildizini topuvchi dastur



7

# Funksiya: Faktorialni hisoblash
Function FaktorialHisobla($son) {
$natija = 1
for ($i = 1; $i -le $son; $i++) {
$natija *= $i
}
return $natija
}

# O'yin boshlandi


Function Boshlash {
Write-Host "Faktorialni hisoblash o'yini boshlandi!"
}

# Dastur ishga tushirish


Boshlash

do {
$kirilganSon = Read-Host "Faktorialni hisoblash uchun bir son kiriting:"


# Sonni tekshirish
if ($kirilganSon -match '^\d+$') {
$faktorial = FaktorialHisobla $kirilganSon
Write-Host "$kirilganSon faktoriali: $faktorial"
} else {
Write-Host "Noto'g'ri kiritish! Faqat butun sonlarni kiriting."
}

$yangiSonKiritish = Read-Host "Yana bir faktorialni hisoblash uchun son kiritasizmi? (ha/yo'q)"


if ($yangiSonKiritish -ne 'ha') {
Write-Host "O'yin uchun rahmat!"
break
}
} while ($true)

Bir sonni factorial sonini hisoblaydigan o’yin



Download 1,4 Mb.




Download 1,4 Mb.