# python 3.6.2
while True:
reelLength = int(input('Введите длину мотка (от 1 до 100): '))
if reelLength <= 100 and reelLength >= 1:
break
else:
print('Неверный ввод!')
reelNum = 0
while True:
segmentLength = int(input('Введите длину куска (от 1 до 100): '))
if segmentLength <= 100 and segmentLength >= 1:
if segmentLength < reelLength:
reelLength -= segmentLength
reelNum += 1
continue
if segmentLength == reelLength:
reelLength -= segmentLength
reelNum += 1
print(f'Количество кусков: {reelNum:d}; Длина остатка: {reelLength:d}')
break
else:
print('Неверный ввод!')
#include <iostream>
using namespace std;
int main()
{
int a[12],k;
cout<<"Massive before: ";
srand(time(NULL));
for(int i=0;i<12;i++)
{
a[i]=(rand() % 25 -12);
cout<<a[i]<<" ";
if((i+1)%4==0) cout<<" | ";
}
for(int j=0;j<3;j++)
{
for(int i=0;i<2;i++)
{
k=a[j*4+i];
a[j*4+i]=a[3+j*4-i];
a[3+j*4-i]=k;
}
}
cout<<endl<<"Massive : ";
for(int i=0;i<12;i++)
{
cout<<a[i]<<" ";
if((i+1)%4==0) cout<<" | ";
}
getch();
return 0;
}