O‘ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGYALARI VA KOMMUNIKATSIYALARINI RIVOLANTIRISH VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI SAMARQAND FILIALI
“KOMPYUTER INJINIRINGI” FAKULTETI
“DASTURIY INJINIRINGI” YO’NALISHI
“DASTURLASH USLUBLARI VA PARADIGMALARI ” FANIDAN
MUSTAQIL ISHI
Bajardi: 312-guruh talabasi
Yoqub Hamzayev.
SAMARQAND – 2020
1-hafta mustaqil yechish uchun topshiriqlar.
Quyida keltirilgan masalalar uchun C++ va SQL tillarida dastur kodlarini mos
jadval kataklariga yozing.
1.Elementlari 5,1,3,9,12,583,998,7538,72,53,71,85,7,2,9 sonlardan iborat massiv
berilgan. Mazkur massivning elementlari orasidan eng kattasi topilsin (20%).
#include
using namespace std;
int main(){
int mas[] = {5,1,3,9,12,583,998,7538,72,53,71,85,7,2,9};
int maxx = mas[0];
for(int i = 1; i < sizeof(mas)/sizeof(*mas); i++){
if(maxx < mas[i])
maxx = mas[i];
}
cout << maxx;
}
|
SELECT MAX(numb)
FROM table ;
|
2.Elementlari 5,1,3,9,12,583,998,7538,72,53,71,85,7,2,9 sonlardan iborat massiv
berilgan. Mazkur massivning elementlari orasidan eng kichigi topilsin (20%).
#include
using namespace std;
int main(){
int mas[] = {5,1,3,9,12,583,998,7538,72,53,71,85,7,2,9};
int maxx = mas[0];
for(int i = 1; i < sizeof(mas)/sizeof(*mas); i++){
if(maxx > mas[i])
maxx = mas[i];
}
cout << maxx;
}
|
SELECT_MIN'>SELECT MIN(numb)
FROM table ;
|
3.Quyida quyoshning sayyoralarini tavsiflovchi Planets jadvali berilgan. Xalqasi bor(HavingRangs) sayyoralar ekranga chiqarilsin. (20%).
#include
using namespace std;
struct Planets{
string planet_name;
bool having_rings;
};
int main()
{
Planets plan[5];
plan[0].planet_name = "Mars";
plan[1].planet_name = "Saturn";
plan[2].planet_name = "Neptune";
plan[3].planet_name = "Mercury";
plan[4].planet_name = "Venus";
plan[0].having_rings = false;
plan[1].having_rings = true;
plan[2].having_rings = true;
plan[3].having_rings = false;
plan[4].having_rings = false;
for(int i=0; i<5; i++){
if(plan[i].having_rings)
cout<
}
}
|
SELECT PlanetName
FROM Planets WHERE HavingRings = ‘Yes’;
|
4. Quyida Universities jadvali berilgan. Fakultetlari soni 20 tadan ko’p bo’lgan
universitetlar soni aniqlansin (20%).
#include
using namespace std;
struct Universities {
string university_name;
int faculties ;
};
int main()
{
Universities univer[7];
univer[0].university_name = "Perm State Nati
onal Research University";
univer[1].university_name = "Saint Petersbur
g State University";
univer[2].university_name = "Novosibirsk Sta
te University";
univer[3].university_name = "Moscow State Un
iversity";
univer[4].university_name = "Higher School o
f Economics";
univer[5].university_name = "Ural Federal Un
iversity";
univer[6].university_name = "National Resear
ch Nuclear University";
univer[0].faculties = 12;
univer[1].faculties = 24;
univer[2].faculties = 13;
univer[3].faculties = 39;
univer[4].faculties = 12;
univer[5].faculties = 19;
univer[6].faculties = 10;
for(int i=0; i<7; i++){
if(univer[i].faculties > 20)
cout<l;
}
}
|
SELECT PlanetName
FROM Planets WHERE HavingRings SELECT UniversityName
FROM Universities WHERE Faculties > 20;= ‘Yes’;
|
5. Elementlari 5,1,3,0,12,0,998,0,72,53,0,85,7,2,9 sonlardan iborat massiv berilgan. Massivda nechta 0 borligini aniqlansin (20%).
#include
using namespace std;
int main()
{
int a[] = {5,1,3,0,12,0,998,0,72,53,0,85,7,2,9};
int counter = 0;
for(int i=0; iif(a[i] == 0)
counter++;
}
cout<}
|
SELECT COUNT(numb)
FROM table WHERE numb = 0;
|
Do'stlaringiz bilan baham: |