|
4-Amaliy ish. 311-21-guruh talabasi Salohiddinov Ramzjan Toshkent 2023
|
Sana | 06.12.2023 | Hajmi | 86,62 Kb. | | #112762 |
Bog'liq Ramzjan paradigma
O‘ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA
KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI
TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
Dasturlash uslublari va paradigmalari
fanidan
4-Amaliy ish.
311-21-guruh talabasi
Salohiddinov Ramzjan
Toshkent 2023
Task 4. Karobka va sharlar.
Task 5. Katta va kichiklar uchun bilet narxi.
Task 6. Natural sonlarni ikkilik sanoq ko’rinishiga o’tkazib, ular orasida 1 ta nolga ega sonlar.
1.
#include
#include
#include // Use cmath for math functions
using namespace std;
int main() {
int n[] = {3, 1, 0, 0, 0, 1, 2, 0, 2, 1};
vector a;
vector b;
int step = 0;
for (int i = 0; i < 10; i++) {
if (n[i] > 1) {
a.push_back(i);
}
if (n[i] == 0) {
b.push_back(i);
}
}
for (int i = 0; i < a.size(); i++) {
cout << "a=" << a[i] << endl;
}
for (int i = 0; i < b.size(); i++) {
cout << "b=" << b[i] << endl;
}
for (int i = 0; i < min(a.size(), b.size()); i++) {
int c = a[i] - b[i];
step += abs(c);
}
cout << "Natija=" << step;
return 0;
}
2.
#include
using namespace std;
int main()
{
int min,max,katta,k;
cout<<"K=";cin>>katta;
cout<<"k=";cin>>k;
if(katta==0) {
cout<<"Kattalarsiz kirish mumkin emas!";
return 0;
}
if(katta>=k){
if(k>0){
min=katta;
max=katta+k-1;
}else {
min=katta;
max=katta+k;
}
}
if(kattamin=k;
max=katta+k-1;
}
cout<<"min="<cout<<"max="<main();
}
3.
#include
#include
#include // Use cmath for math functions
using namespace std;
int main() {
int n[] = {3, 1, 0, 0, 0, 1, 2, 0, 2, 1};
vector a;
vector b;
int step = 0;
for (int i = 0; i < 10; i++) {
if (n[i] > 1) {
a.push_back(i);
}
if (n[i] == 0) {
b.push_back(i);
}
}
for (int i = 0; i < a.size(); i++) {
cout << "a=" << a[i] << endl;
}
for (int i = 0; i < b.size(); i++) {
cout << "b=" << b[i] << endl;
}
for (int i = 0; i < min(a.size(), b.size()); i++) {
int c = a[i] - b[i];
step += abs(c);
}
cout << "Natija=" << step;
return 0;
}
function zeroCounting(n) {
let count = 0;
let numbers = [];
for (let i = m; i <= n; i++) {
const binaryString = i.toString(2);
if (/^1*0{1}1*$/.test(binaryString)) {
count++;
numbers.push(binaryString);
}
}
return count+" "+`(${numbers})`;
}
const m = 1;
const n = 1000000000;
const result = zeroCounting(n);
console.log(`Count [${m} to ${n}]: ${result}`);
|
| |