| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1322 人关注过本帖
标题:老师布置的作业,不太懂这个loop guarded command怎么实现的,还有这个斐波 ...
取消只看楼主 加入收藏
regor
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2020-9-29
结帖率:0
收藏
已结贴  问题点数:20 回复次数:0 
老师布置的作业,不太懂这个loop guarded command怎么实现的,还有这个斐波那契数怎么产生的?
Write a program/function C++ that will implement loop guarded command (LGC).

Your program/function will take 3 non-zero, positive integers, e.g., 3, 6, and 12.

The first two integers should have different values, e.g., 3 and 6, and will be used to create a list of Boolean expressions as follows:

the first Boolean expression will be defined as “x%3 == 0”, i.e., check if x%3 has 0 remainder.  
the second Boolean expression will be defined as “x%4 ==0”
the third Boolean expression will be defined as “x%5==0”
The last Boolean expression will be defined as “x%6==0”
The statement corresponding to each Boolean expression defined above will print out the Fibonacci numbers that are less than the integer used in the Boolean expression.  E.g., the statement for the second Boolean expression x%4==0 will print out “0 1 1 2 3”, for the fourth Boolean expression x%6==0 will print out “0 1 1 2 3 5”.

The third input integer to your program/function will be used as input value for variable x defined in the Boolean expression.  E.g., if the third input integer is 12, the first, second, and fourth Boolean expressions will have a true value (i.e., 12%3 = 12%4 = 12%6 = 0). The LGC will randomly, non-deterministically choose ONE of 3 corresponding statements to print out the Fibonacci numbers, as described above.

If the third input integer to your program function failed all Boolean expressions defined, your program should throw runtime errors and be terminated.
搜索更多相关主题的帖子: integer The and expression program 
2020-09-29 10:59
快速回复:老师布置的作业,不太懂这个loop guarded command怎么实现的,还有这个 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017080 second(s), 11 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved