#include
#include
void lasagu(char x)
{
textcolor(WHITE);
clrscr();
long int suma=1, sum=1;
int a,m[20],n[20][20],count[20],i,j,p[20],l,k=0,prime[50],o=0,g[50],q=0;
n[0][0]=1;
// textcolor(RED);
if(x=='g')
printf("\n\n\n\t Deter mination of G C D:\n\n");
else if(x=='l')
{
printf("\n\n\n\t Deter mination of L C D:\n\n");
}
else if(x=='b')
{
printf("\n\n\n\t Deter mination ofL C D && G C D:\n\n");
}
printf("\n\t How many number you want to Enter:");
scanf("%d",&a);
for(i=0;i
{
// textcolor(RED);
printf("\n\t Element [%d]",i+1);
scanf("%d",&m[i]);
}
prime[0]=2;prime[1]=3;prime[2]=5;prime[3]=7;
j=4;
for(i=2;i<100;i++)
{
if(i%2==0||i%3==0||i%5==0||i%7==0)
continue;
else
{
prime[j]=i;
j++;
}
}
for(i=0;i
{
n[i][0]=1;
p[i]=m[i];
count[i]=0;
k=1;
while(m[i]!=1)
{
j=0;
while(j<100)
{
if(m[i]%prime[j]==0)
{
n[i][k]=prime[j];
m[i]=m[i]/prime[j];
count[i]=count[i]+1;
k++;
j=100;
}
else
j++;
}
}
}
for(i=0;i
{
printf("\n ");
printf("%d =",p[i]);
for(j=0;j<=count[i];j++)
{
if(j==count[i])
printf("%d",n[i][j]);
else
printf("%d*",n[i][j]);
}
}
for(i=0;i
{
for(j=0;j<=count[i];j++)
{
for(k=i+1;k
{
l=0;
while(l<=count[k])
{
if(n[i][j]==1)
{
l++;
continue;
}
else
if(n[i][j]==n[k][l])
{
n[k][l]=1;
l=count[k];
q=q+1;
}
l++;
}
}
g[o]=n[i][j];
o++;
if(q==a)
sum=sum*n[i][j];
q=1;
}
}
for(i=0;i
{
for(j=0;j<=count[i];j++)
suma=suma*n[i][j];
}
// textcolor(RED);
cprintf(" ");
if(x=='g')
{
printf("\n\t G C D=%ld",sum);
}
else if(x=='l')
{
printf("\n\t L C D=%ld",suma);
}
else if(x=='b')
{
printf("\n\t L C D=%ld",suma);
printf("\n\t G C D=%ld",sum);
}
}
void main()
{
int t=0;char ch;
textcolor(WHITE);
textbackground(BLUE);
clrscr();
printf("\n\t Welcome to the L C D && GCD");
// textcolor(RED);
printf("\n\n\t \\****************\\");
printf("\n\n\t MENU");
printf("\n\n\t Press L for lasagu : ");
printf("\n\t Press G for Gasagu : ");
printf("\n\t Press B for BOATH : ");
printf("\n\t Press E for exit: ");
while(t==0)
{
// textcolor(GREEN);
printf("\n\n\t Enter a number L or G or B or E:");
l:
ch =getch();
switch(ch)
{
case'l':
case'L':
lasagu(ch);
break;
case'g':
case'G':
lasagu(ch);
break;
case'b':
case'B':
lasagu(ch);
break;
case'e':
t=1;
break;
default:
goto l;
}
}
}
0 comments:
Post a Comment