1) а) на Java class example{ public static void main (String[] args){ int k = 0, j = 0; for (int i = 0; i < 10; i++){ k = k + 5; j = j + k; if (i == 9) System.out.print(k); else System.out.print(k + " + "); } System.out.print(" = " + j); } } б) на Pascal var a,b,c:integer; begin for a:=1 to 10 do begin b:=b+5; c:=c+b; if (a = 10) then write(b) else write(b, ' + ') end; write(' = ', c); end. 2) а) на Java class example{ public static void main(String args[]){ for (int x = 50; x >= 40; x--){ double y = (5 * x) + (Math.pow(x, 2)); int i = (int) y; System.out.println(i); } } } б) на Pascal var y:real; x:integer; begin for x:=50 downto 40 do begin y:=(5*x)+sqr(x); writeln(y:0:0); end; end.
#include <stdio.h>
int main()
{
float a1,an, d,Sn,n;
scanf("%f %f %f", &a1, &an, &d);
n=(an-a1+d)/d;
Sn=((a1+an)/2)*n;
printf("%0.1f", Sn);
return 0;
}
2)
#include <stdio.h>
int main()
{
int i;
for ( i=50;i>=40;i--)
printf("%d\n", 5*i+i*i);
return 0;
}
class example{
public static void main (String[] args){
int k = 0, j = 0;
for (int i = 0; i < 10; i++){
k = k + 5;
j = j + k;
if (i == 9)
System.out.print(k);
else
System.out.print(k + " + ");
}
System.out.print(" = " + j);
}
}
б) на Pascal
var a,b,c:integer;
begin
for a:=1 to 10 do
begin
b:=b+5;
c:=c+b;
if (a = 10) then write(b)
else write(b, ' + ')
end;
write(' = ', c);
end.
2) а) на Java
class example{
public static void main(String args[]){
for (int x = 50; x >= 40; x--){
double y = (5 * x) + (Math.pow(x, 2));
int i = (int) y;
System.out.println(i);
}
}
}
б) на Pascal
var y:real;
x:integer;
begin
for x:=50 downto 40 do
begin
y:=(5*x)+sqr(x);
writeln(y:0:0);
end;
end.