Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Массивы 3 файл ( задачи )
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- #include <stdio.h>
- #include <algorithm>
- #include <vector>
- using namespace std;
- int main() {
- srand(time(0));
- vector <int> a(7);
- int i;
- int c = 0;
- cout << "Массив до сортировки: ";
- for(i = 0;i < 7; i++){
- a[i] = 0 + rand() % 100;
- cout << a[i] << " ";
- if(a[i] >= 25 && a[i] <= 75){
- c++;
- }
- }
- cout << endl << endl;
- cout << "Количество элементов на отрезке [25;75]: " << c;
- cout << endl << endl;
- sort(a.begin(),a.end());
- cout << "Отсортированный массив: ";
- for(int i = 0; i < 7; i++){
- cout << a[i] << " ";
- }
- cout << endl;
- int b[6][4];
- for(int i=0; i<6; i++){
- for (int j=0; j<4; j++){
- b[i][j] = 0 + rand() % 100;
- cout << b[i][j] << " ";
- }
- cout << endl;
- }
- cout << endl;
- cout << endl;
- int max_i = -1;
- int k = 0;
- for(int i=0; i<6; i++){
- for (int j=0; j<4; j++){
- if(b[k][j] > max_i){
- max_i = b[k][j];
- }
- }
- cout <<"Максимальны эл " << k+1 << " строки " << max_i << endl;
- k++;
- max_i = 0;
- }
- cout << endl;
- int max_j = -1, k2 = 0;
- while(k2!=4){
- for(int i=0; i<6; i++){
- if(b[i][k2] > max_j){
- max_j = b[i][k2];
- }
- }
- cout << "Максимальный эл " << k2+1 << " столбца " << max_j << endl;;
- k2++;
- max_j = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment