×î´ó¹«Ô¼ÊýºÍ×îС¹«±¶ÊýµÄÈýÖÖ³¬¼òµ¥Ëã·¨
1¡¢Õ·×ªÏà³ý·¨£ºÈ¡Á½¸öÊýÖÐ×î´óµÄÊý×ö³ýÊý£¬½ÏСµÄÊý×ö±»³ýÊý£¬ÓÃ×î´óµÄÊý³ý½ÏСÊý£¬Èç¹ûÓàÊýΪ0£¬Ôò½ÏСÊýΪÕâÁ½¸öÊýµÄ×î´ó¹«Ô¼Êý£¬Èç¹ûÓàÊý²»Îª0£¬ÓýÏСÊý³ýÉÏÒ»²½¼ÆËã³öµÄÓàÊý£¬Ö±µ½ÓàÊýΪ0£¬ÔòÕâÁ½¸öÊýµÄ×î´ó¹«Ô¼ÊýΪÉÏÒ»²½µÄÓàÊý¡£
ÈçÏÂʾÀý³ÌÐò:
#include<stdio.h>
int main()
{
int x, y, z, m, n;
printf("ÇëÊäÈëÁ½¸öÊý£º");
scanf_s("%d%d", &x, &y);
m = x, n = y;
while (y != 0)
{
z = x%y;
x = y;
y = z;
}
printf("×î´ó¹«Ô¼ÊýÊÇ: %d\n", x);
printf("×îС¹«±¶ÊýÊÇ: %d\n", m*n / x);
system("pause");
return 0;
}
2¡¢Ïà¼õ·¨£ºÈ¡Á½¸öÊýÖеÄ×î´óµÄÊý×ö¼õÊý£¬½ÏСµÄÊý×ö±»¼õÊý£¬ÓÃ×î´óµÄÊý¼õȥСÊý£¬Èç¹û½á¹ûΪ0£¬Ôò±»¼õÊý¾ÍÊÇÕâÁ½¸öÊýµÄ×î´ó¹«Ô¼Êý£¬Èç¹û½á¹û²»Îª0£¬Ôò¼ÌÐøÓÃÕâÁ½¸öÊýÖÐ×î´óµÄÊý¼õ½ÏСµÄÊý£¬Ö±µ½½á¹ûΪ0£¬Ôò×î´ó¹«Ô¼ÊýΪ±»¼õÊý¡£
ÈçÏÂʾÀý³ÌÐò:
#include<stdio.h>
int main()
{
int x, y, m, n;
printf("ÇëÊäÈëÁ½¸öÊý£º");
scanf_s("%d%d", &x, &y);
m = x, n = y;
while (x!=y)
{
if (x>y)
x = x-y;
else
y = y-x;
}
printf("×î´ó¹«Ô¼ÊýÊÇ: %d\n", x);
printf("×îС¹«±¶ÊýÊÇ: %d\n", m*n / x);
system("pause");
return 0;
}
3¡¢Çî¾Ù·¨£º½«Á½¸öÊý×÷±È½Ï£¬È¡½ÏСµÄÊý£¬ÒÔÕâ¸öÊýΪ±»³ýÊý·Ö±ðºÍÊäÈëµÄÁ½¸öÊý×ö³ý·¨ÔËË㣬±»³ýÊýÿ×öÒ»´Î³ý·¨ÔËË㣬ֵ¼õÉÙ1£¬Ö±µ½Á½¸öÔËËãµÄÓàÊý¶¼Îª0£¬Ôò¸Ã±»³ýÊýΪÕâÁ½¸öÊýµÄ×î´ó¹«Ô¼Êý¡£
ÈçÏÂʾÀý³ÌÐò:
#include<stdio.h>
int main()
{
int x, y, i, m, n;
printf("ÇëÊäÈëÁ½¸öÊý£º");
scanf_s("%d%d", &x, &y);
m = x, n = y;
for (i = 1; i <= x; i++)
{
if (x%i == 0 && y%i == 0)
}
for (i = x; i > 0; i--)
{
if (x%i == 0 && y%i == 0)
}
printf("×î´ó¹«Ô¼ÊýÊÇ: %d\n", i);
printf("×îС¹«±¶ÊýÊÇ: %d\n", m*n / i);
system("pause");
return 0;
}