网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
以下程序是用来计算两个非负数之间的最大公约数我们假设x,y中最大的那个数的长度为n,基本运算时间复杂度为O(1),那么该程序的时间复杂度为()
A.O(1)
B.O(logn)
C.O(n)
D.O(n^2)
参考答案
更多 “ 以下程序是用来计算两个非负数之间的最大公约数我们假设x,y中最大的那个数的长度为n,基本运算时间复杂度为O(1),那么该程序的时间复杂度为()A.O(1)B.O(logn)C.O(n)D.O(n^2) ” 相关考题
考题
以下程序的功能是:利用指针指向三个整型变量,并通过指针运算找出三个数中的最大值,输出到屏幕上,请填空: main() {int x,y,z,max,*px,*py,*pz,*pmax; scanf(“%d%d%d”,x,y,z); px=x; py=y; pz=z; pmax= __________________ if(*pmax*py)*pmax=*py; if(*pmax*pz)*pmax=*pz; printf(“max=%d\\n”,max); }
考题
下列函数过程的作用是计算x和y的最大公约数。请填空。Private Sub Command1_ Click()Dim x As Integer, y As Integer, Result As Integerx = InputBox (“请输入第一个数”)y = InputBox (“请输入第二个数”)Result =______Print x; "和"; y; "的最大公约数为: "; ResultEnd SubPrivate Function GYS (ByVal A As Integer, ByVal B As Integer)Dim T As IntegerT = A Mod BDo While ______A = BB = TT = A Mod BLoop______End Function
考题
设函数findbig已定义为求3个数中的最大值。以下程序将利用函数指针调用findbig函数,请填空。main(){ int findbig(int,int,int); int (*f)(),x,y,z,big; f=; scanf("%d%d%d",x,y,z); big=(*f)(x,y,z); printf("big=%d\n",big);}
考题
以下程序用来计算由键盘输入的N个数中正数之和,负数之和,正数的个数,负数的个数。其中用C累加负数之和,IC累加负数的个数,D累加正数之和,ID累加正数的个数。Privae Sub Commandl_ClickN=10C=0:IC=0:D=0:ID=0For =1 To NA=Val(1nputBox(“请输入A”))IFA<0 Then C=C+A:IC=IC+1lf A>O Then D=Next KPrint"负数的个数为:",
考题
下述程序计算从键盘输入的两个数的最大公约数,请填空。(答案中请不要带空格,答案之间用3个空格键间隔) #include<iostream> #include<iomanip> using namespace std; void main() { int x, y, r, gcd; cout<<"Enter two number: n "; cin>> x>>y; r= ; while () { x=y; y=r; r= ; } cout<<"The result is "<<y<<endl; }
考题
3、下述程序计算从键盘输入的两个数的最大公约数,请填空。(答案中请不要带空格,答案之间用3个空格键间隔) #include<iostream> #include<iomanip> using namespace std; void main() { int x, y, r, gcd; cout<<"Enter two number: \n "; cin>> x>>y; r= ; while () { x=y; y=r; r= ; } cout<<"The result is "<<y<<endl; }
热门标签
最新试卷