P. S. Ixtiyoriy dasturlash tilidan foydalanish mumkin




Download 64,54 Kb.
Sana18.12.2023
Hajmi64,54 Kb.
#122163
Bog'liq
BekmirzaMadaminov7-8


O’zbekiston Respublikasi Raqamli Texnologiyalar Vazirligi
Muhammad al-Xorazmiy nomidagi Toshkent Axborot Texnologiyalari Universiteti
Dasturiy Injiniring fakulteti talabasi Madaminov Bekmirzaning
Dasturlash uslublari va paradigmalar fanidan 7-8-shaxsiy topshiriqlari

Bajardi: Madaminov Bekmirza


PSP004-2 guruh
Qabul qildi: Atoyev Suhrob
G’afurovich

7-8-topshiriqlar


Task 7. Bolalarni dam olish maskaniga yuborish uchun kerak bo’ladigan avtobuslar soni.
Task 8. Shaxmatdagi otni yurishi orqali telefon raqamlarini hosil qilish.

P.S. Ixtiyoriy dasturlash tilidan foydalanish mumkin.

7. Dastur kodi (C++)
#include
#include
using namespace std;
int main(){
int k,b,m,n,x;
cout<<"Kattalar soni: "; cin>>k;
cout<<"Bolalar soni: "; cin>>b;
cout<<"O'rindiqlar soni: "; cin>>m;
n = m - 2;
x = b/n;
if(k<2 or b<0 or m<3)
{
cout<<"Impossible";
return 0;
}
if(b%n!=0){
x = x + 1;
}
if(k>=x*2 || k+b<=m){
cout<<"True"<cout<}
else{
cout<<"impossible";
}
return 0;
}

Dastur natijasi


8. Dastur kodi (Python)


import random
numbers = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
]
x_ = [1, 2, 3]
y_ = [1, 2, 3]
x__ = []
y__ = []
choices = [1, 0]
n = int(input("Enter a number: "))
def search_num(num):
n = num // 3 + 1 if num % 3 != 0 else num // 3
m = num % 3 if num % 3 != 0 else 3
return [[n - 1, m + 2], [n - 1, m - 2], [n + 1, m - 2], [n + 1, m + 2], [n - 2, m + 1], [n - 2, m - 1],
[n + 2, m + 1], [n + 2, m - 1]]
def check_num(nums, visited):
a = []
for i in nums:
if i[0] in x_ and i[1] in y_ and (i[0], i[1]) not in visited:
a.append([i[0], i[1]])
return random.choice(a)
for i in range(50):
visited_positions = set()
phone = str(n)
finish = 6
if n == 5:
print("xato")
if n == 0:
k = [4, 6]
phone += str(random.choice(k))
finish -= 1
for i in range(finish):
last = int(phone[-1])
k = search_num(last)
add_num = check_num(k, visited_positions)
visited_positions.add((add_num[0], add_num[1]))
phone += str(numbers[add_num[0] - 1][add_num[1] - 1])
print(phone)

Dastur natijasi



Download 64,54 Kb.




Download 64,54 Kb.

Bosh sahifa
Aloqalar

    Bosh sahifa



P. S. Ixtiyoriy dasturlash tilidan foydalanish mumkin

Download 64,54 Kb.