输入两个正整数num1,num2,求其最大公约数. #include"stdio.h" ________________________ intmain() { intd; intnum1,num2;printf("pleaseinputtwonumbers: "); scanf("%d,%d",&num1,&num2); ________________________ printf("gongyueshu:%d ",d); return0;} intgongyue(inta,intb) { ________________________ while(b) { temp=a%b; a=b; b=temp; } ________________________ }
举一反三
- 【单选题】以下程序的输出结果是()#include<stdio.h>intmain(void){intnum=0;while(num<=2){num++;printf("%d ",num);}return0;} A. 1 B. 1 2 C. 1 2 3 D. 1 2 3 4
- 如下代码用欧几里得算法求两个正整数的最大公约数。num1,num2=eval(input("请输入两个正整数")) if num1<num2: num1,num2=num2,num1 #保证num1大 while_____________: temp=num1%num2 num1=num2 num2=temp print("最大公约数是:",num2)其中第4行下划线的代码应该是_______ A: num2%num1==0 B: num2%num1!=0 C: num1%num2==0 D: num1%num2!=0
- int num1=12, num2=9; num1 =num1 & num2;执行后num的值为8。( )
- 假设存在变量$str1="abc";$str2="ABC";$numl=23;$num2=45,下面哪一组表达式的运算结果是假值?( ) A: $str1<;$str2&&$num1 <;$num2 B: $str1>;$str2&&$num1 <;$num2 C: $str1<;$str2}}$num 1 <;$num2 D: $str 1 >;$str2||$num1 >;$num2
- main(){int num=0;while(num<;=2){num++;printf("%d\n",num);}}