#include <iostream> #include <cstdlib> #include <ctime> int main() { using namespace std; cout << "Enter size of array: "; int N; cin >> N; int * ARR = new int[N]; srand(time(0)); int i; for (i = 0; i < N; ++i) ARR[i] = rand() % 100 + 1;
cout << "Here is an original array:\n"; for (i = 0; i < N; ++i) cout << ARR[i] << " "; cout << endl;
int temp = ARR[N - 1]; for (i = N - 1; i > 0; --i) ARR[i] = ARR[i - 1]; ARR[0] = temp;
cout << "\nHere is a new array:\n"; for (i = 0; i < N; ++i) cout << ARR[i] << " "; cout << endl;
#include <cstdlib>
#include <ctime>
int main()
{
using namespace std;
cout << "Enter size of array: ";
int N;
cin >> N;
int * ARR = new int[N];
srand(time(0));
int i;
for (i = 0; i < N; ++i)
ARR[i] = rand() % 100 + 1;
cout << "Here is an original array:\n";
for (i = 0; i < N; ++i)
cout << ARR[i] << " ";
cout << endl;
int temp = ARR[N - 1];
for (i = N - 1; i > 0; --i)
ARR[i] = ARR[i - 1];
ARR[0] = temp;
cout << "\nHere is a new array:\n";
for (i = 0; i < N; ++i)
cout << ARR[i] << " ";
cout << endl;
return 0;
}
#include <iostream>
#include <string>
bool is_palindrome(const std::string& s) {
std::string r(s);
std::reverse(r.begin(), r.end());
return s == r;
}
int main() {
std::string s1,s2;
setlocale(LC_ALL, "Russian");
std::cout << "Введите число 1: ";
std::getline(std::cin, s1);
std::cout << "Введите число 2: ";
std::getline(std::cin, s2);
if (is_palindrome(s1)|| is_palindrome(s2))
std::cout << "Одно из введенных чисел является палиндромом " << std::endl;
else
std::cout << "Ни одно из введенных чисел не является палиндромом " << std::endl;
return 0;
}