[ create a new paste ] login | about

Link: http://codepad.org/HJ5B5PcO    [ raw code | output | fork | 3 comments ]

C, pasted on Aug 23:
#include<stdio.h>
#include<conio.h>

int main()
{
	int a, b, i;

	do{
		printf("\nNhap vao so nguyen duong a = ");
		scanf_s("%4d", &a);
		if (a < 0)
		{
			printf("\nGia tri nhap vao khong hop le. Xin kiem tra lai !");
		}
	} while (a < 0);

	do{
		printf("\nNhap vao so nguyen duong b = ");
		scanf_s("%4d", &b);
		if (b < 0)
		{
			printf("\nGia tri nhap vao khong hop le. Xin kiem tra lai !");
		}
	} while (b < 0);

	int Max = a > b ? a : b;
	int Min = a < b ? a : b;
	if(a == b)
		return a;
	else
	{
		for(i = Max; i < a * b; i++)
			if(i % a == 0 && i % b == 0)
			{
				return i;
				break;
			}
	}
	printf("\nBCNN la %d", i);
	getch();
	return 0;
}


Output:
1
Line 17: error: conio.h: No such file or directory


Create a new paste based on this one


Comments:
posted by kid_banz on Oct 5
#include<stdio.h>
#include<conio.h>

int main()
{
int a, b,i=1;
printf("nhap a: ");
scanf_s("%d", &a);
printf("nhap b: ");
scanf_s("%d", &b);

for (i;i<=a*b; i++)
if (i%a == 0 && i%b == 0)
{
printf("%4d", i);
break;
}

_getch();

}
reply
posted by thinhdeptrai on Apr 25

reply
posted by thinhdeptrai on Apr 25
#include<bits/stdc++.h>
int main(){
int a,b,i;
do{
printf("nhap a=");
scanf("%d",&a);
if(a<=0){
printf("xin hay nhap lai");
}
}while(a<=0);
do{
printf("nhap b=");
scanf("%d",&b);
if(b<=0){
printf("xin hay nhap lai");
}}while(b<=0);
int max=a>b?a:b;
int min=a<b?a:b;
if(a==b)
return a;
else
for(i=max;i<a*b;i++)
if(i%a==0&&i%b==0){

break;}

printf("BCNN la %d",i);

return 0;
}
reply