Created
September 20, 2024 14:55
-
-
Save Darklega228/6be812d9806e684d438e5945c5fa5d6a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
//Домашнє завдання 2 | |
// Задание 1 | |
/*int main() | |
{ | |
setlocale(0, ""); | |
const int size = 5; | |
int Masive[size] = { 1, 2, 3, 4, 5 }; | |
int Naznacheniya[size]; | |
int* Vihidnyi = Masive; | |
int* Vhidnyi = Naznacheniya; | |
for (int i = 0; i < size; ++i) | |
{ | |
*(Vhidnyi + i) = *(Vihidnyi + i); | |
} | |
cout << "Элементы в массиве назначения: "; | |
for (int i = 0; i < size; ++i) | |
{ | |
cout << Naznacheniya[i] << " "; | |
} | |
cout << "\n"; | |
}*/ | |
//Задание 2 | |
/*int main() | |
{ | |
setlocale(0, ""); | |
const int size = 5; | |
int Masive[size] = { 1, 2, 3, 4, 5 }; | |
int* start = Masive; | |
int* end = Masive + size - 1; | |
while (start < end) | |
{ | |
int temp = *start; | |
*start = *end; | |
*end = temp; | |
start++; | |
end--; | |
} | |
cout << "Обратный массив: "; | |
for (int i = 0; i < size; ++i) | |
{ | |
cout << Masive[i] << " "; | |
} | |
cout << "\n"; | |
}*/ | |
// Задание 3 | |
int main() | |
{ | |
setlocale(0, ""); | |
const int size = 5; | |
int Masive[size] = { 1, 2, 3, 4, 5 }; | |
int Naznacheniya[size]; | |
int* Istochnik = Masive; | |
int* Mesto = Naznacheniya + size - 1; | |
for (int i = 0; i < size; ++i) | |
{ | |
*Mesto = *(Istochnik + i); | |
Mesto--; | |
} | |
cout << "Элементы в обратном целевом массиве: "; | |
for (int i = 0; i < size; ++i) { | |
cout << Naznacheniya[i] << " "; | |
} | |
cout << "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment