阅读以下说明和C函数,填补代码中的空缺,将解答填入答题纸的对应栏内。
[说明1]
函数isPrime(int n)的功能是判断n是否为素数。若是,则返回1,否则返回0。素数是只能被1和自己整除的正整数。例如,最小的5个素数是2,3,5,7,11。
[C函数] int isPrime(int n) { int k, t; if (n==2) return 1; if(n<2 || ______)return 0; /*小于2的数或大于2的偶数不是素数// t=(int)Sqrt(n)+1; for(k=3; k<t; k+=2) if(______) return 0; return 1; }
[说明2]
函数int minOne(int art[],int k)的功能是用递归方法求指定数组中前k个元素中的最小者,并作为函数值返回。
[C函数]int minOne(int arr[],int k){int t;assert(k>0);if(k==1)return ______;t=minOne(arr+1,______);if(arr[0]<t)return amr[0];return ______;}
正确答案及解析
正确答案
解析
n%2==0,或!(n%2),或其等价形式
n%k==0,或!(n%k),或其等价形式
arr[0],或*arr,或其等价形式
k-1,或其等价形式
t
你可能感兴趣的试题
( )is that it provides guidance and direction on how quality will be managed and verified throughout the project.
-
- A.Plan Quality Management
- B.Manage Quality
- C.Control Quality
- D.Project Charter
- 查看答案
( )the process of determining,documenting,and managing stakeholder needs and requirements to meet Project objectives.
-
- A.Plan Scope Management
- B.Collection Requirements
- C.Validate Scope
- D.Control Scope
- 查看答案
The information security management system preserves the confidentiality,integrity and availability of information by applying a( ).
-
- A.technology management process
- B.resource management process
- C.quality management process
- D.risk management process
- 查看答案
( )is a decentralized database,ensure that the data will not be tampered with and forged.
-
- A.Artificial intelligence
- B.Blockchain
- C.Sensing technology
- D.Big datA
- 查看答案
( )puts computer resources on the web,and must meet the requirements of super capacity,super concurrency,super speed and super security.
-
- A.Cloud computing
- B.Big datA
- C.Blockchain
- D.Internet of things
- 查看答案