Var R1, R2, R3, S1, S2, S3: Integer; begin writeln('Введите размеры рации и чемодана'); readln(R1, R2, R3, S1, S2, S3); if ((R1 < S1) and (R2 < S2) and (R3 < S3)) or ((R3 < S3) and (R2 < S1) and (R1 < S2)) or ((R1 < S1) and (R2 < S3) and (R3 < S3)) or ((R2 < S2) and (R1 < S3) and (R3 < S1)) or ((R2 < S1) and (R3 < S2) and (R1 < S3)) or ((R1 < S2) and (R3 < S1) and (R2 < S3)) then WriteLn('ПОМЕЩАЕТСЯ') else WriteLn('НЕ ПОМЕЩАЕТСЯ'); end.
R1, R2, R3, S1, S2, S3: Integer;
begin
writeln('Введите размеры рации и чемодана');
readln(R1, R2, R3, S1, S2, S3);
if ((R1 < S1) and (R2 < S2) and (R3 < S3)) or
((R3 < S3) and (R2 < S1) and (R1 < S2)) or
((R1 < S1) and (R2 < S3) and (R3 < S3)) or
((R2 < S2) and (R1 < S3) and (R3 < S1)) or
((R2 < S1) and (R3 < S2) and (R1 < S3)) or
((R1 < S2) and (R3 < S1) and (R2 < S3)) then
WriteLn('ПОМЕЩАЕТСЯ')
else
WriteLn('НЕ ПОМЕЩАЕТСЯ');
end.
#include<conio.h>
#include<stdio.h>
#include <stdlib.h>
#include<time.h>
#define N 25
#define K 3
int prime(int num)
{ int i;
for(i=2;i<=num/2;i++)
if(num%i==0) break;
if(i==num/2+1 || num==1) return num;
else return 0;
}
int maxPos(int A[])
{ int i,max,mPos;
max=0;
for(i=0;i<N;i++)
if(A[i]>max)
{ max=A[i];
mPos=i;
}
return mPos;
}
int main()
{ int i,j,X[N],Y[N],pos;
srand(time(NULL));
for(i=0;i<N;i++)
{ X[i]=rand()%30+1;
Y[i]=prime(X[i]);
}
printf("Original array\n");
for(i=0;i<N;i++)
printf("%3d",X[i]);
printf("\nArray-masque of prime numbers\n");
for(i=0;i<N;i++)
printf("%3d",Y[i]);
printf("\n\n");
for(j=0;j<K;j++)
{ pos=maxPos(Y);
printf("%3d in position %3d targeted\n",X[pos],pos);
Y[pos]=-1;
X[pos]=-1;
}
j=0;
for(i=0;i<N;i++)
if(X[i]!=-1)
{ Y[j]=X[i];
j++;
}
printf("\nResult:\n");
for(i=0;i<j;i++)
printf("%3d",Y[i]);
getchar();
return 0;
}
Объяснение: