Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <locale>
- #include <iomanip>
- using namespace std;
- // КОЛ-ВО и ЗНАЧЕНИЯ ДВУХ упорядоченных ПО УБЫВАНИЮ одномерных массивов ХРАНЯТСЯ в текстовике.
- // Получить из них 3-ий упорядоченный ПО УБЫВАНИЮ. БЕЗ СОРТИРОВКИИ
- ifstream f("ishod.txt", ios::in);
- int count1, count2;
- void Print_mas(int* mass, int n){ //Функция для печати матрицы
- int i = 0;
- while (i < n){
- cout << setw(6) << mass[i] << " ";
- i++;
- }
- cout << endl;
- }
- int* form_mas(int count){
- int* massive = new int[count];
- int a = 0;
- while (a < count){
- f >> massive[a];
- a++;
- }
- return massive;
- }
- void massive3(int* mass1, int* mass2){
- int i = 0, j = 0, a = 0;
- int* mass3 = new int[count1 + count2];
- while (a < (count1 + count2)){
- if (mass1[i] > mass2[j]){
- mass3[a] = mass1[i];
- i++;
- }
- else{
- mass3[a] = mass2[j];
- j++;
- }
- a++;
- }
- cout << "А вот блять и третий массив без всякой там сортировки" << endl;
- Print_mas(mass3, count1 + count2);
- }
- void main()
- {
- setlocale(LC_ALL, "rus");
- f >> count1;
- f >> count2;
- int* mass1 = form_mas(count1);
- cout << "Исходный массив : " << endl;
- Print_mas(mass1, count1);
- int* mass2 = form_mas(count2);
- cout << "Исходный массив : " << endl;
- Print_mas(mass2, count2);
- massive3(mass1, mass2);
- f.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment