首页 > 试题广场 >

const SIZE = 100; Var P...

[填空题]
const
  SIZE = 100;
Var
  P : array [1..SIZE] of integer;
  N, tot, cn, i : integer;
Begin
  Readln(n);
  For i:=1 to n do
    P[i] := 1;
  Tot := 0;
  For i:=2 to n do
  Begin
    If p[i] = 1 then
      Tot := tot + 1;
    Cn := i * 2;
    While cn <= n do
    Begin
      P[cn] := 0;
      Cn := cn + I;
    End;
  End;
  Writeln(tot);
End.
输入:30;
输出:1

这道题你会答吗?花几分钟告诉大家答案吧!