Const n = 10;
var a:array [1..n] of integer;
i,min,imin:integer; p:longint;
begin
for i:=1 to n do
begin
a[i]:=random(21)-10;
write(a[i],' ');
end;
writeln;
min:=a[1]; imin:=1;
p:=1;
for i:=1 to n do
begin
if a[i]<min then begin min:=a[i]; imin:=i; end;
if a[i]<0 then p:=p*a[i];
end;
writeln('min = ',min,' imin = ',imin);
writeln('p = ',p);
end.
Пример:
9 5 10 -5 2 10 0 8 -8 2
<span>min = -8 imin = 9
p = 40</span>
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Введите число: \nА = ");
int x, y = sc.nextInt();
sc.close();
x = y * y;
System.out.println("A^2 = " + x);
y *= x;
System.out.println("A^3 = " + y);
x *= y;
System.out.println("A^5 = " + x);
y = x * x;
System.out.println("A^10 = " + y);
y *= x;
System.out.println("A^15 = " + y);
}
}
Сумма двух элементов a[1] и a[4] для данного массива равна 22