/*最大公约数和最小公倍数*/ #include"stdio.h" void main() { int m,n,j,k,r; do { printf ( "请按输入数字m,n:\n" ); scanf ( "%d%d",&m,&n ); } while ( m<0||n<0 ); r=m*n; while ( m%n!=0 ) { j=m%n; m=n; n=j; k=r/n; } printf ( "最大公约数是:%d\n",n ); printf ( "最小公倍数是:%d\n",k ); }