Задача на Паскаль! СОСТАВЬТЕ БЛОК СХЕМУ: var n: longint; sum: integer; begin readln(n); sum := 0; while n > 0 do begin if n mod 10 mod 2 = 0 then sum := sum + n mod 10; n := n div 10; end; writeln(sum); end.
var i,j,n:longint; f:boolean; begin writeln('Введите число'); readln(n); if n<2 then writeln('Простых делителей нет') else begin write('Число ',n,' ','= 1'); for i:=2 to n do if n mod i=0 then begin f:=true; j:=2; while f and(j<=round(sqrt(i/2)))do begin if i mod j=0 then f:=false else j:=j+1; end; if f then write('*',i); end; end; end.
Код на Java:
import java.util.Scanner;
public class Znanija{
public static void main(String args[]) {
double number;
Scanner input = new Scanner(System.in);
System.out.println("Enter the number: ");
number = input.nextInt();
if(number>100) {
System.out.println("\nThe entered number is greater than 100, so we divide by 10: " + number/10);
}
else {
System.out.println("\nThe entered number is less than 100, read its square, and multiply by 100: " + Math.pow(number, 2)*100);
}
}
}
Псевдокод:integer number
print("Enter the number: ")
input.number
if number>100
print("The entered number is greater than 100, so we divide by 10: ", number/10)
else
print("The entered number is less than 100, read its square, and multiply by 100: ", number*number*100)
var i,j,n:longint;
f:boolean;
begin
writeln('Введите число');
readln(n);
if n<2 then writeln('Простых делителей нет')
else
begin
write('Число ',n,' ','= 1');
for i:=2 to n do
if n mod i=0 then
begin
f:=true;
j:=2;
while f and(j<=round(sqrt(i/2)))do
begin
if i mod j=0 then f:=false
else j:=j+1;
end;
if f then write('*',i);
end;
end;
end.
Тестовое решение:
Введите число
2345
Число 2345 = 1*5*7*35*67