Объяснение:
h,w = int(input().split())
c,p = int(input().split())
s = []
roadm = []
parks = []
cp = []
for i in range(1, h+1):
for j in range(1, w+1):
s.append([i,j])
for k in s:
if k[0]==1 or k[1]==1:
roadm.append(s.pop(k))
for t in s:
if t[0] == 2 or t[1] == 2:
cp.append(s.pop(t))
for y in s:
if y[0] == (f[0]+1 for f in cp) and y[1] == (f[1]+1 for f in cp) and y[0] == (f[0]-1 for f in cp) and y[1] == (f[1]-1 for f in cp):
parks.append(s.pop(y))
a = []
b = []
for o in s:
a.append(o[0])
b.append(o[1])
print(min(a))
print(min(b))
Відповідь:
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
void SetArray(int *A,int N){
for(int i = 0; i < N; i++){
A[i] = rand() % 10 + 1;
}
void PrintArray(int *A,int N){
for(int i = 0;i < N; i++){
cout << A[i] << " ";
void expression(int *A,int N,int k,int l){
for(int i = k; k < l; k++ , l--){
swap(A[k], A[l]);
int main(){
srand(time(NULL));
setlocale(LC_ALL , "Ukrainian");
int N,k,l;
cout << "Введiть розмiр масиву: ";
cin >> N;
int *A = new int[N];
SetArray(A,N);
PrintArray(A,N);
cout << "\nВведiть k: ";
cin >> k;
cout << "Введiть l: ";
cin >> l;
expression(A,N,k,l);
delete[] A;
return 0;
Объяснение:
h,w = int(input().split())
c,p = int(input().split())
s = []
roadm = []
parks = []
cp = []
for i in range(1, h+1):
for j in range(1, w+1):
s.append([i,j])
for k in s:
if k[0]==1 or k[1]==1:
roadm.append(s.pop(k))
for t in s:
if t[0] == 2 or t[1] == 2:
cp.append(s.pop(t))
for y in s:
if y[0] == (f[0]+1 for f in cp) and y[1] == (f[1]+1 for f in cp) and y[0] == (f[0]-1 for f in cp) and y[1] == (f[1]-1 for f in cp):
parks.append(s.pop(y))
a = []
b = []
for o in s:
a.append(o[0])
b.append(o[1])
print(min(a))
print(min(b))
Відповідь:
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
void SetArray(int *A,int N){
for(int i = 0; i < N; i++){
A[i] = rand() % 10 + 1;
}
}
void PrintArray(int *A,int N){
for(int i = 0;i < N; i++){
cout << A[i] << " ";
}
}
void expression(int *A,int N,int k,int l){
for(int i = k; k < l; k++ , l--){
swap(A[k], A[l]);
}
}
int main(){
srand(time(NULL));
setlocale(LC_ALL , "Ukrainian");
int N,k,l;
cout << "Введiть розмiр масиву: ";
cin >> N;
int *A = new int[N];
SetArray(A,N);
PrintArray(A,N);
cout << "\nВведiть k: ";
cin >> k;
cout << "Введiть l: ";
cin >> l;
expression(A,N,k,l);
PrintArray(A,N);
delete[] A;
return 0;
}