FOR语句
1.计算并输出2的n次方和2的-n次方。已知n=0,1,2,3,4,5,...,15
2. 求斐波拉契数列a0,a1,a2,a3...a20
3. 若三位数abc,a^3+b^3+c^3=abc,则称为水仙花数。例如153,1^3+5^3+3^3=153,因此153为水仙花数。输出100--999的所有水仙花数
4.输出1--999中能被3整除,且至少有一位数字是5的所有整数。
WHILE 语句
1.输入x的值(|x|<1),按下列公式计算s
s=x+(x^2/2)+(x^3/3)+(x^4/4)+....
直到最后一项的绝对值小于0.00001为止。
REPEAT语句
1. 求下列式中n的最大值: 2^2+4^2+6^2+...+n^2<1500
2.输入x的值,按公式计算:
1-(x^2/2!)+(x^4/4!)-(x^6/6!)+.......
直到最后一项的绝对值小于0.000001时为止
for 语句:
1、
program exercise;
var n,i,x:longint;
        y:real;
begin
readln(n);
 x:=1;
 y:=0;
 for i:=1 to n do
  begin
   x:=x*2;
   y:=1/x;
  end;
 writeln(x:5,' ',y:0:10);
end.
2、
var x,y,a,t,n:qword;
begin
  readln(n);
   x:=0;
   y:=1;
   t:=3;
  write(' ':13,'0':13,'1':13);
  repeat
   a:=x;
   x:=y;
   y:=a+x;
   t:=t+1;
   write(y:13);
   if t mod 5 =0 then writeln;
  until t-1=n;
end.
3、
var i,j,k:integer;
begin
 for i:=1 to 9 do
  for j:=0 to 9 do
   for k:=0 to 9 do
    if i*i*i+j*j*j+k*k*k=100*i+10*j+k then
     write(100*i+10*j+k,' ');
end.
4、
var a,b,c,i:integer;
begin
 for i:=1 to 999 do
  begin
   a:=i div 100;
   b:=(i-100*a) div 10;
   c:=i mod 10;
   if (i mod 3=0) and ((a=5) or (b=5) or (c=5)) then
   write(i,' ');
  end;
end.
while语句:
var s,n,x:real;
  i:integer;
begin
 write('Please input x:');
 readln(x);
 n:=1; i:=1;
 while (n/i)>=1e-5 do
  begin
  n:=n*x;
  s:=n/i+s;
  inc(i);
  end;
 writeln(s:0:5);
end.
repeat语句:
1、
var s,i,x,y:integer;
begin
 s:=0;
repeat
 x:=2*i;
 i:=i+1;
 y:=x*x;
 s:=s+y;
 until s>1500;
writeln(x);
end.
2、
var x,j,i,k,m,a,b:longint;
          t,p:real;
begin
 writeln('Please input x');
 readln(x);
 a:=0;b:=1;m:=1;t:=1;i:=1;
  repeat
  a:=x*x;
  b:=a*b;
  i:=2*i;
  for k:=1 to i do
    m:=m*k;
  p:=b/m;
  j:=j+1;
  if j mod 2=0 then t:=t-p else
   t:=t+p;
  until p<1e-6;
 writeln(t:0:8);
end.
最后一题弄了好久,好像错了,实在木招了