free pascal练习题求解答 急! 求代码

1个回答

  • var

    a,b,c,d,e:integer;

    begin

    //原2

    write('(...)');

    writeln;

    for a:=1 to 5 do

    begin

    for c:=1 to 3 do

    begin

    for b:=1 to 5-a do write(' ');

    for b:=1 to a do write('*');

    for b:=a-1 downto 1 do write('*');

    for b:=1 to 5-a do write(' ');

    end;

    writeln;

    end;

    writeln;

    //2

    write('(2)');

    writeln;

    write('please write a number:');

    readln(e);

    while e>1 do

    begin

    if e mod 2=1

    then begin

    write('3*',e,'+1=',e*3+1,' ');

    e:=e*3+1;

    end

    else begin

    write(e,' div 2=',e div 2,' ');

    e:=e div 2;

    end;

    end;

    write('OK');

    writeln;

    writeln;

    //3

    write('(3)');

    writeln;

    a:=101;

    repeat

    a:=a+1;

    until (a mod 3=2)and(a mod 5=3)and(a mod 7=5);

    write(a);

    writeln;

    writeln;

    //4

    write('(4)');

    writeln;

    for d:=100 to 999 do

    begin

    a:=d div 100;

    b:=(d-a*100) div 10;

    c:=d mod 10;

    if a*a*a+b*b*b+c*c*c=d then writeln(d);

    end;

    readln;

    是我,望采纳