Axborottexnologiyalari universiteti telekommunikatsiyalar fakulteti



Download 0,74 Mb.
Sana03.05.2023
Hajmi0,74 Mb.
#934763
Bog'liq
Dasturlash amaliy topshiriq (1)


O’ZBEKISTON RESPUPLIKASI AXBOROT TEXNALOGIYALARI VA
KOMMUNUKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT
AXBOROTTEXNOLOGIYALARI UNIVERSITETI
TELEKOMMUNIKATSIYALAR FAKULTETI


DASTURLASH 2


Bajardi: 830-22- guruh talabasi


Eshqobilov Xushnudbek
Tekshi: Gulyamova Dilfuza
TOSHKENT 2023

Berilgan vazifalarni bajarishda kiruvchi qiymatlar matinli fayldan o’qib olinishi kerak.


1.Topshiriq. Berilgan float turidagi to’plam qiymatlarining butun(nuqtadan oldin) qismi 2- to’plamga, kasr(nuqtadan keyin) qismi 3- to’plamga joylashtiruvchi va ularni ekranga chiqaruvchi dastur tuzing. Ikkala to’plamdan ham bir xil qiymatli elemetlar o’chirilib Saralangan to’plam hosil qilinsin hamda uning qiymatlari ekranga chiqarilsin.


#include
#include
#include
#include
#include
#include

using namespace std;

void prepareTextFileToReadParametrs() {
srand(time(NULL));
fstream file;
file.open("TextFile.txt", ios::out);
if (file.is_open()) {
int l = rand() % 10 + 5;
for (int i = 0; i < l; i++)
file << (1.0 * (rand() % 10000)) / 100.0 << endl;
file.close();
}
cout << "The file named \"TextFile.txt\" is filled randomly!\n" << endl;
}

void print(set s) {


for (auto it = s.begin(); it != s.end(); it ++)
cout << *it << "\t";
}

int main() {


prepareTextFileToReadParametrs();
fstream file;
set s, s1, s2;
string line;
file.open("TextFile.txt", ios:: in);
if (file.is_open()) {
while (getline(file, line))
s.insert(stof(line));
file.close();
}
cout << "The set of float numbers that read from file is below 👇\n";
print(s);
for (auto it = s.begin(); it != s.end(); it++) {
s1.insert((int) *it);
s2.insert(((int)(*it * 100)) % 100);
}
cout << "\n\nThe set of Numbers before point! 👇\n";
print(s1);
cout << "\n\nThe set of Numbers after point! 👇\n";
print(s2);
set res;
for (auto it = s1.begin(); it != s1.end(); it++)
res.insert(*it);
for (auto it = s2.begin(); it != s2.end(); it++)
res.insert(*it);
cout << "\n\nThe result of thwo merged sets is following.👇\n";
print(res);
return 0;
}



2. Topshiriq.
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define stringify( name ) #name

using namespace std;

enum Subject {
Math,
History,
Geography
};

enum Group {


FirstGroup,
SecondGroup
};

class Student {


private:
string name, surname;
Subject subject;
Group group;
int score;
public:
Student (string name, string surname, Subject subject, Group group, int score) {
this -> name = name;
this -> surname = surname;
this -> subject = subject;
this -> group = group;
this -> score = score;
}
string getName () {
return name;
}
string getSurname () {
return surname;
}
Subject getSubject () {
return subject;
}
Group getGroup () {
return group;
}
int getScore () {
return score;
}
void print () {
cout << "Fullname: " << name + " " + surname;
cout << "\tSubject: " << subject;
cout << "\tGroup: " << group;
cout << "\tScore: " << score << endl;
}
};

void show (Student* s) {


s -> print();
}

void prepareTextFileToReadParametrs() {


srand(time(NULL));
string name = "Name", surname = "Surname";
fstream file;
file.open("TextFile.txt", ios::out);
if (file.is_open()) {
int l = rand() % 5 + 5;
for (int s = Math; s <= Geography; s++)
for (int i = 0; i < l; i++) {
file << name << (i + 1) << endl;
file << surname << (i + 1) << endl;
file << s << endl;
file << rand() % 2 << endl;
file << rand() % 4 + 2 << endl;
}
file.close();
}
cout << "The file named \"TextFile.txt\" is filled randomly!\n" << endl;
}

int main() {


prepareTextFileToReadParametrs();
multiset students;
fstream file;
int i = 0;
string name, surname;
Subject subject;
Group group;
int score;
string line;
file.open("TextFile.txt", ios::in);
if (file.is_open()) {
while (getline(file, line))
switch (i++ % 5) {
case 0: name = line;
break;
case 1: surname = line;
break;
case 2: subject = (Subject) stoi(line);
break;
case 3: group = (Group) stoi(line);
break;
case 4: score = stoi(line);
Student* st = new Student(name, surname, subject, group, score);
students.insert(st);
break;
}
file.close();
}
cout << "\nThese are all students list." << endl;
for_each(students.begin(),students.end(), show);
multimap groups;
for(Student* it = students.begin(); it != students.end(); it++) {
int key = it -> getGroup();
int v = 0;
if (groups.contains(key))
v = groups.find(key);
groups.insert(pair(key, v + 1));
}
return 0;
}



Download 0,74 Mb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish