0-variant 1-masala 20. Vector hosil qiling va ga karrali elementlar sonini uning yigindisiga nisbati topilsin


Download 18.6 Kb.
Sana08.03.2023
Hajmi18.6 Kb.
#1251628
Bog'liq
1-laboratoriya ishi 20-variant 1-masala



Muhammad al-Xorazmiy nomidagi
Tashkent Axborot Texnologiyalari Universiteti
AKT sohasida iqtisod va menejment fakulteti
120-20 ETo' guruh talabasi
Raufova Madinaning Dasturlash 2 fanidan
bajargan 1-laboratoriya ishi

1-laboratoriya ishi
20-variant
1-masala
20.VECTOR hosil qiling va 7 ga karrali elementlar sonini uning yigindisiga nisbati topilsin.

#include


#include
#include
using namespace std;
int main() {
string line;
int number;
vector < int > numbers;
cout << "Sonlarni bo'sh joy bilan ajratib kiriting: ";
getline(cin, line);
istringstream stream(line);
while (stream >> number)
numbers.push_back(number);
int sum = 0;
int sevens;
for (int i = 0; i < numbers.size(); i++) {
sum += numbers[i];
if (numbers[i] == 7) sevens++;
}
cout << "Natija: " << 1.0 * sevens / sum << endl;
system("pause");
return 0;
}

2-masala
20.Berilgan char turidagi to’plamning kata harfdan iborat elementlarini kichik harfga o’girib, 2- to’plamni va kichik harfdan iborat elementlarini katta harfga o’girib, 3- to’plamni hosil qiluvchi hamda ularni ekranga chiqaruvchi dastur tuzing.

#include


#include
#include

using namespace std;

int main() {
char input[100];
char upper[100];
char lower[100];

cout << "1- to'plam elementlarini kiriting: ";


cin >> input;
for (int x = 0; x < 100; x++)
if (input[x] != 'x\0') {
upper[x] = toupper(input[x]);
lower[x] = tolower(input[x]);
} else break;

cout << "\n2-to'plam: " << upper;


cout << "\n3-to'plam: " << lower << "\n";

system("pause");


return 0;
}

Download 18.6 Kb.

Do'stlaringiz bilan baham:




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