#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
signed main(){
int n;
cin >> n;
vector<int> a(n);
for(auto &i: a) cin >> i;
for(int i = 0; i < n / 2; i++) swap(a[i], a[n - i - 1]);
for(auto &i: a) cout << i << " ";
}
#include <iostream>
#include<vector>
using namespace std;
int square(int x){
for (int i = 1; i <= 45; ++i){
if (i * i <= x){
continue;
}
return (i - 1) * (i - 1);
}
}
int main()
{
int x, y, xwas, ywas, xywas;
cin >> x >> y;
xwas = square(x);
ywas = square(y);
xywas = square(x + y);
if (xwas + ywas < xywas){
cout << "Petya gives paint to Vasya";
}
else if (xwas + ywas == xywas){
cout << "Equal";
}
else {
cout << "Petya leaves paint to himself";
}
return 0;
}
Объяснение:
Решение не моё, но вдруг понадобиться)
Объяснение:
#include <iostream>
unsigned perfectSquareLessOrEqual(unsigned n) {
unsigned sum = 0;
for (unsigned i = 1; (sum + i) <= n; i += 2)
sum += i;
return sum;
}
int main() {
unsigned x, y;
std::cin >> x >> y;
const unsigned a = perfectSquareLessOrEqual(x) + perfectSquareLessOrEqual(y);
const unsigned b = perfectSquareLessOrEqual(x + y);
if (a < b)
std::cout << "Petya gives paint to Vasya";
else if (a > b)
std::cout << "Petya leaves paint to himself";
else
std::cout << "Equal";
return 0;
}
import random
n = int(input("Количество цифр в массиве : "))
numbers = [random.randint(1, n) for i in range(n)]
print(f"Массив : {numbers}")
print(f"В обратном порядке : {numbers[::-1]}")
Объяснение:
Простой :
a = "uzbekistan"
a = a[::-1]
print(a)
Результат:
natsikebzu