procedure roots(a, b, c: real; var x1, x2: real;
var fail: boolean);
begin
var d : = b * b - 4 * a * c;
if d < 0 then
fail : = true
else
begin
fail : = false;
d : = sqrt(d);
x1 : = (-b - d) / (2 * a);
x2 : = (-b + d) / (2 * a);
end
end;
begin
var x1, x2: real;
var fail: boolean;
loop 3 do
begin
var (a, b, c) : = readreal3('введи a, b, c: ');
roots(a, b, c, x1, x2, fail);
if fail then
println('нет действительных корней')
else if x1 = x2 then
println('x =', x1)
else
println('x1 =', x1, ' x2 =', x2)
end
end.
Поделитесь своими знаниями, ответьте на вопрос:
ответ:
using system;
public class test
{
static void task2()
{
console.write("task 2: ");
int i = 0;
while(i < 10)
{
i++;
console.write(" " + i);
}
console.writeline();
}
static void task3()
{
console.write("task 3: ");
int i = -1;
while(i < 10)
{
i++;
if (i % 2 == 1)
{
continue;
}
console.write(" " + i);
}
console.writeline();
}
public static void main()
{
task2();
task3();
}
}
объяснение:
task2 выведет целые числа от 1 до 10.
task3 выведет четные целые числа от 0 до 10.