Muhammad al-xorazmiy nomidagi toshkent axborot texnologiyalari universiteti akt sohasida kasb talimi yo’nalishi
tarix 18.04.2023 ölçüsü 1,77 Mb. #100165
Dilbar dedline2 Bu səhifədəki naviqasiya: include include include using namespace std; class Famous_futballer { public Famous_futballer(string nm, int ag, string cl, int gs, int yc, int rc, string fg) { name = nm; age = ag; club = cl; goals_scored = gs; Famous_futballer player3("Neymar Jr", 30, "Paris Saint-Germain", 155, 60, 1, "Solo goal vs Flamengo"); players.push_back(player1); players.push_back(player2);
MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
AKT SOHASIDA KASB TALIMI YO’NALISHI
650-22 GURUX TALABASI
MIRZAAKBAROVA DILBAR
BAJARGAN 2 – AMALIYOT ISHI
Bajardi: Mirzaakbarova Dilbar
Tekshirdi: Babajonov Mo’min
TOSHKENT 2022
Mashxur futbolistlar haqida ma’lumotlar berilgan (class Famous_futballer). Eng ko‘p urilgan gollar, sariq va qizil kartochkalar , chiroyli va muhim gollari bo‘yicha mashxur futbaklchini qidirib topuvchi dastur tuzing..
#include
#include
#include
using namespace std ;
class Famous_futballer {
public:
string name;
int age;
string club;
int goals_scored;
int yellow_cards;
int red_cards;
string famous_goal;
Famous_futballer(string nm, int ag, string cl , int gs, int yc, int rc, string fg) {
name = nm;
age = ag;
club = cl;
goals_scored = gs;
yellow_cards = yc;
red_cards = rc;
famous_goal = fg;
}
void display_info() {
cout << "Name: " << name << endl;
cout << "Age: " << age << endl;
cout << "Club: " << club << endl;
cout << "Goals scored: " << goals_scored << endl;
cout << "Yellow cards: " << yellow_cards << endl;
cout << "Red cards: " << red_cards << endl;
cout << "Famous goal: " << famous_goal << endl;
}
};
int main() {
vector players;
Famous_futballer player1("Lionel Messi", 34, "Paris Saint-Germain", 700, 77, 4, "Maradona-like goal vs Getafe");
Famous_futballer player2("Cristiano Ronaldo", 37, "Manchester United", 778, 112, 12, "Overhead kick vs Juventus");
Famous_futballer player3("Neymar Jr", 30, "Paris Saint-Germain", 155, 60, 1, "Solo goal vs Flamengo");
players.push_back(player1);
players.push_back(player2);
players.push_back(player3);
for (int i = 0; i < players.size(); i++) {
cout << "Player " << i+1 << endl;
players[i].display_info();
cout << endl;
}
return 0;
}
Vectorda qidirilgan ixtiyoriy son nechta ekanligini aniqlovchi va ushbu sonni o‘chiruvchi funksiyalar yarating.
#include
#include
using namespace std;
int count_occurrences(vector vec, int num) {
int count = 0;
for (int i = 0; i < vec.size(); i++) {
if (vec[i] == num) {
count++;
}
}
return count;
}
void remove_first_occurrence(vector &vec, int num) {
for (int i = 0; i < vec.size(); i++) {
if (vec[i] == num) {
vec.erase(vec.begin() + i);
break;
}
}
}
int main() {
vector numbers = {1, 3, 5, 2, 3, 4, 3, 6, 8, 3};
int count = count_occurrences(numbers, 3);
cout << "The number 3 occurs " << count << " times in the vector." << endl;
remove_first_occurrence(numbers, 3);
cout << "After removing the first occurrence of 3, the vector is: ";
for (int i = 0; i < numbers.size(); i++) {
cout << numbers[i] << " ";
}
cout << endl;
return 0;
}
String turidagi To‘plam berilgan. Undagi elementlarni char turidagi A massivga joylashtirib , ixtiyoriy to‘plam mavjudligini aniqlovchi dastur tuzing.
#include
#include
using namespace std;
int main() {
string s = "hello world";
char A[s.length() + 1];
for (int i = 0; i < s.length(); i++) {
A[i] = s[i];
}
A[s.length()] = '\0';
bool is_empty = true;
for (int i = 0; i < s.length(); i++) {
if (A[i] != '\0') {
is_empty = false;
break;
}
}
if (is_empty) {
cout << "The array is empty." << endl;
} else {
cout << "The array is not empty." << endl;
}
return 0;
}
X to‘plamning tub qiymatlaridan D to‘plamni tashkil eting , so‘ngra X to‘plamdan ushbu tub qiymatlarini o‘chiruvchi dastur tuzing
#include
#include
#include
using namespace std;
bool isPrime(int n) {
if (n <= 1) {
return false;
}
int root = sqrt(n);
for (int i = 2; i <= root; i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
vector createD(vector X) {
vector D;
for (int i = 0; i < X.size(); i++) {
if (isPrime(X[i])) {
D.push_back(X[i]);
}
}
return D;
}
void removePrimes(vector& X) {
vector result;
for (int i = 0; i < X.size(); i++) {
if (!isPrime(X[i])) {
result.push_back(X[i]);
}
}
X = result;
}
int main() {
vector X = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
vector D = createD(X);
cout << "X: ";
for (int i = 0; i < X.size(); i++) {
cout << X[i] << " ";
}
cout << endl;
cout << "D: ";
for (int i = 0; i < D.size(); i++) {
cout << D[i] << " ";
}
cout << endl;
removePrimes(X);
cout << "X (tub sonlari o'chirilgan): ";
for (int i = 0; i < X.size(); i++) {
cout << X[i] << " ";
}
cout << endl;
return 0;
}
Dostları ilə paylaş: