C语言:求大佬帮我看一下哪里错了(大一卑微小白)
#include<stdio.h>int main()
{
int a,b,y=1,n,a1,b1;
printf("请输入两个正整数:");
scanf("%d%d",&a,&b);
a1=a;
b1=b;
for(;y!=0;)
{
y=a%b;
a=b;
b=y;}
n=a1*b1/b;
printf("最大公因数为:%d\n最小公倍数为:%d\n",b,n);
return 0;
}
#include <stdio.h> unsigned gcd( unsigned a, unsigned b ) { for( ; b!=0; ) { unsigned t = a%b; a = b; b = t; } return a; } int main( void ) { unsigned a, b; printf( "请输入两个正整数: " ); scanf( "%u%u", &a, &b ); unsigned g = gcd( a, b ); unsigned l = a/g*b; printf( "最大公因数为:%d\n", g ); printf( "最小公倍数为:%d\n", l ); }