在1-n中,找出能同时满足用3除余2,用5除余3,用7除余2的所有整数的个数,如果没有请输出0。 pascal

云城之主
2012-01-16 · 超过17用户采纳过TA的回答
知道答主
回答量:50
采纳率:0%
帮助的人:40.7万
展开全部
我只给你打出关键程序及解释
sum:=0;//个数记录在sum里
for i=1 to n do//枚举i
if (i mod 3 =2)and(i mod 5=3)and(i mod 7=2)//你的条件
then inc(sum);//满足条件则sum+1
write(sum);//输出

参考资料: myself

已赞过 已踩过<
你对这个回答的评价是?
评论 收起
Mine四剑客
2012-01-16
知道答主
回答量:27
采纳率:0%
帮助的人:6.5万
展开全部
var
n,i,s:longint;
begin
read(n);
s:=0;
for i:=1 to n do
if (i mod 3=2)and(i mod 5=3)and(i mod 7=2) then s:=s+1;
writeln(s);
end.
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
刹那风雨爱上你
2012-01-17
知道答主
回答量:8
采纳率:0%
帮助的人:4.1万
展开全部
var n:看你需要;
procedure init;
begin
readln(n);
end;
procedure pd;
var i,t:随你;
begin
for i:=1 to n do
if (3 mod i=2) and (5 mod i=3) and (7 mod i=2) then inc(t);
if t=0 then writeln(0)
else writeln(t);
end;
begin
init;
pd;
end.
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式