1樓:匿名使用者
program t1;
varn,i:longint;
f:boolean;
begin
readln(n);
i:=2;f:=true;
while (i<=trunc(sqrt(n))) and f doif n mod i=0 then f:=falseelse inc(i);
if f then writeln('yes')else writeln('no');
readln;readln;
end.
不知回答是否合意,如有問題請指出,本人感激不盡!
2樓:匿名使用者
var n,i,j,k:longint;
t:boolean;
begin
readln(n);
if n=1 then begin
writeln('no');
halt;
end;
t:=true;
for i:=2 to trunc(sqrt(n)) do if n mod i=0 then begin
t:=false;
break;
end;
if t then writeln('yes') else writeln('no');
end.
3樓:
program project1;
vari,t:word;
n:integer;
begin
readln(n);
for i:=2 to (n-1) do
if n mod i=0 then begininc(t);break;end;
if t=0 then writeln('yes')else writeln('no');
readln;
end.
輸入正整數n計算11315的前n項
include int main for i 1 i n i printf sum 3f n sum return 0 示例執行結果 20sum 2.480 include int main void for int i 0 iprintf 數列前 d 項之和為 g n n,s return 0 v...
1定義陣列,然後輸入正整數n 1n 10 ,再輸入n個整數並存放到該陣列,輸出他們的平均值
int a 20 int i 0 int ncount 0 cout input ncount cin ncount int a new int ncount 1 int nsum 0 memset a 0 ncount 1 for i 0 i ncount i cout nsum ncount e...
C程式設計 輸入正整數n,再輸入n個學生的成績,計算平均分
include int main int argc,char argv printf a等的成績個數有 d個 n count a printf b等的成績個數有 d個 n count b printf c等的成績個數有 d個 n count c printf d等的成績個數有 d個 n count ...