- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main ()
- •Int main ()
- •Int main ()
- •Int main() {
- •Int main()
- •Int main()
- •Int main()
- •Int main() {
- •Int main() {
- •Int main(){
- •Int main() {
- •Int main() {
- •Int main()
- •Int main()
Int main()
{
int a;
cout<<"a="; cin>>a;
if (a>99)
{ int b=a%100;
int c=b%10;
int d=b/10;
int f=a/100;
cout<<a<<" saninin cifrlary: ";
cout<<f<<" , "<<d<<" zhane "<<c<<endl;
if (f==4 || d==4 || c ==4 || f==7 || d==7 || c==7)
{cout<<"4 nemese 7 cifrlarynyn biri "<<a<<" saninda bar"<<endl; }}
else cout<<a<<" sany uw tanbaly emes"<<endl;
system("pause");
return
0;}
b) #include<iostream>
#include<math.h>
using namespace std;
Int main()
{
int a;
cout<<"a="; cin>>a;
if (a>99)
{ int b=a%100;
int c=b%10;
int d=b/10;
int f=a/100;
cout<<a<<" saninin cifrlary: ";
cout<<f<<" , "<<d<<" zhane "<<c<<endl;
if (f==3 || d==3 || c ==3 || f==6 || d==6 || c==6 || f==9 || d==9 || c==9)
{cout<<"3,6 nemese 9 cifrlarynyn biri "<<a<<" saninda bar"<<endl; } }
else cout<<a<<" sany uw tanbaly emes"<<endl;
system("pause");
}
25) Известны данные о численности населения (в миллионах жителей) и площа-
ди (в тысячах квадратных километров) 28 государств. Определить макси-
мальную плотность населения в отдельном государстве.
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <windows.h>
using namespace std;
struct countries {
string name;
int people;
int square;
};
Int main()
{ int i;
int check[28];
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
srand(time(0));
countries p[28];
for (i = 0; i < 28; i++) {
cin>>p[i].name;
do p[i].people = (rand()%100)*1000000; while(p[i].people==0);
cout << "Kolichestva jitelei: " << p[i].people;
do p[i].square = (rand()%10)*10000; while(p[i].square==0);
cout << "\nPlowad: " << p[i].square;
check[i]=1.0*p[i].people/p[i].square;
cout << "\n-----------------\n";
}
int min = check[0], index;
for (i=0;i<28;i++) if (check[i] <= min) {
min = check[i]; index = i;
}
cout << "\nStrana s minimalnoi plotnostiu maselenia: " << p[index].name << endl;
return 0;
}
26)
Составить программу:
а) заменяющую значение любого элемента пятой строки двумерного массива
числом 1949;
б) заменяющую значение любого элемента двумерного массива числом a.
#include <iostream>
#include <iomanip>
#include <windows.h>
using namespace std;
Int main() {
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
int m,n,i,j;
cout << "\nVvedite razmer matrici m x n: ";
cin >> m >> n;
int *mas = new int[m*n];
cout << "\nIshodnaia matrica:\n";
for (i = 0; i < m; i++) {
for (j = 0; j < n; j++)
{ *(mas+i*m+j) = rand()%10 + 1;
cout << *(mas+i*m+j) << " ";
} cout << endl;
}
cout << "-------------------" << endl;
for (j = 0; j < n; j++) *(mas+4*m+j) = 1949;
cout << "\nPunkt a) Matrica,v kotoroi elementi piatoi stroki zameneni:\n";
for (i = 0; i < m; i++) {
for (j = 0; j < n; j++)
{
cout << *(mas+i*m+j) << " ";
} cout << endl;
}
cout << endl;
cout << "\nVvedite razmeri matrici m x n: ";
cin >> m >> n;
int *mas1 = new int[m*n];
cout << "\nIshodnaia matrica:\n";
for (i = 0; i < m; i++) {
for (j = 0; j < n; j++)
{ *(mas1+i*m+j) = rand()%10 + 1;
cout << *(mas1+i*m+j) << " ";
} cout << endl;
}
cout << "-------------------" << endl;
int k;
cout << "\nPunkt b)Matrica,v kotoroi elementi piatoi n stroki zameneni: ";
cin >> k;
for (j = 0; j < n; j++) *(mas1+(k-1)*m+j) = 1949;
for (i = 0; i < m; i++) {
for (j = 0; j < n; j++)
{
cout << *(mas1+i*m+j) << " ";
} cout << endl;
}
delete[] mas;
delete[] mas1;
cout << endl;
return 0;
}
27)В массиве хранится информация о баллах, полученных спортсменом-
десятиборцем в каждом из десяти видов спорта. Для выхода в следующий
этап соревнований общая сумма баллов должна превысить некоторое из-
вестное значение. Определить, вышел ли данный спортсмен в следующий
этап соревнований.
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <windows.h>
using namespace std;
