华为机试-求最小公倍数-难度简单

在这里插入图片描述

#include "stdio.h"
int test(int a, int b)
{
	int temp1 = 0;
	
	if ((0 == a)||(0 == b)){
		return 0;
	}
	while (1){
		temp1 += a;
		if ((temp1 % b) == 0){
			break;
		}
	}
	return temp1;
}
int main(void)/*主函数*/
{
	int a = 15;
	int b = 8;
	int c = 0;

	c = test(a, b);
	printf("最小公倍数 = %d\r\n",c);

	
	return 0;
}

猜你喜欢

转载自blog.csdn.net/lala0903/article/details/107501712