1. Составить программу нахождения суммы чисел 5, 10, 15, 20, …50.
2. Найти значения функции у= 5х+х2, при х=50, 49, 48, 47, …, 40.
Ответы на вопрос
Ответил alexooooon
0
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.
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.
Ответил vfhgjcfl
0
1. program summa;
var
i:integer;
begin
i:=5;s:=0;
While( i<=50) do
begin
s:=s+i;
i:=i+5;
end;
write(s);
readln;
end.
var
i:integer;
begin
i:=5;s:=0;
While( i<=50) do
begin
s:=s+i;
i:=i+5;
end;
write(s);
readln;
end.
Новые вопросы