老师布置的作业,不太懂这个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.