pascal语言题 高分悬赏啊!

[复制链接]
查看11 | 回复5 | 2009-4-23 14:34:34 | 显示全部楼层 |阅读模式
题目:输入一个数 判断是不是质数(就是除了一个和它本身没有别的因数的数)
随便什么格式都可以···程序、函数、过程都可以
星期天之前要啊!回答出了高分悬赏!100分以上哦!

回复

使用道具 举报

千问 | 2009-4-23 14:34:34 | 显示全部楼层
program panduan;var i,n:longint;f:boolean;begin readln(n);{输入那个数} f:=true; for i:=2 to trunc(sqrt(x)) do
if n mod i =0 then
begin
f:=false;break;
end;
if f then writeln('yes') else writeln('no');end. 如有疑问给我留言...
回复

使用道具 举报

千问 | 2009-4-23 14:34:34 | 显示全部楼层
function zs(n:integer):boolean;var
i:byte;beginzs:=n>1;for i:=2 to round(sqrt(n)) do
if n mod i=0 then zs:=false;end;var n:integer;beginreadln(n);...
回复

使用道具 举报

千问 | 2009-4-23 14:34:34 | 显示全部楼层
function zhishu(x:integer):boolean;var i:integer;begin if (x=0) or (x=1) then exit(false); if x=2 then exit(true); for i:=2 to trunc(sqrt(x)) doif x mod i=0 then exit...
回复

使用道具 举报

千问 | 2009-4-23 14:34:34 | 显示全部楼层
var i,n:longint;
f:boolean;begin read(n); f:=true; for i:=2 to trunc(sqrt(n)) doif n mod i=0 then f:=false; write(f);end....
回复

使用道具 举报

千问 | 2009-4-23 14:34:34 | 显示全部楼层
function zs(a:integer):boolean;var i:integer;beginzs:=false;for i:=2 to trunc(sqrt(a)) doif a mod i=0 then exit;if a>1 then zs:=true;end;如果函数值是true,就表示a是质数如果函数值...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行