/*************************************************
Write a program to find triad numbers..
1.Each number is a three digit number.
2.All the digits in the three numbers (total 9 digits) should be different.
3.Second number should be twice the first number and third number should be thrice the first number.
For example
219 438 657
267 534 801
date:30/-05-2019
created by:ANIL DURGAM
*****************************************************/
#include <stdio.h>
#include <stdlib.h>
int main()
{
int m,n,p,num;
int i,k,dl,d2,d3;
for(num=100;num<=999/3;num++)/*Loop A*/
{
for (i=num; i<=3 *num; i+=num) /* loop B */
{
k=i;
dl=k%10;
k/=10;
d2=k%10;
k/=10;
d3=k%10;
k/=10;
if(dl==d2 || d2==d3 || d3==dl)
goto nextnum;
} /*Endof loop B*/
for(m=num;m>0;m/=10) /*Loop c*/
{
dl=m%10;
for(n=num*2;n>0;n/=10) /*Loop D*/
{
d2=n%10;
for(p=num*3;p>0;p/=10) /*Loop E*/
{
d3=p%10;
if(dl==d2 || d2==d3 || dl==d3)
goto nextnum;
} /*End of Loop E*/
} /*End of Loop D*/
}/*End of loop C*/
nextnum:
printf("%d\t%d\t%d\n",num,num*2,num*3);
} /*End of loop A*/
//return 0;
}
Write a program to find triad numbers..
1.Each number is a three digit number.
2.All the digits in the three numbers (total 9 digits) should be different.
3.Second number should be twice the first number and third number should be thrice the first number.
For example
219 438 657
267 534 801
date:30/-05-2019
created by:ANIL DURGAM
*****************************************************/
#include <stdio.h>
#include <stdlib.h>
int main()
{
int m,n,p,num;
int i,k,dl,d2,d3;
for(num=100;num<=999/3;num++)/*Loop A*/
{
for (i=num; i<=3 *num; i+=num) /* loop B */
{
k=i;
dl=k%10;
k/=10;
d2=k%10;
k/=10;
d3=k%10;
k/=10;
if(dl==d2 || d2==d3 || d3==dl)
goto nextnum;
} /*Endof loop B*/
for(m=num;m>0;m/=10) /*Loop c*/
{
dl=m%10;
for(n=num*2;n>0;n/=10) /*Loop D*/
{
d2=n%10;
for(p=num*3;p>0;p/=10) /*Loop E*/
{
d3=p%10;
if(dl==d2 || d2==d3 || dl==d3)
goto nextnum;
} /*End of Loop E*/
} /*End of Loop D*/
}/*End of loop C*/
nextnum:
printf("%d\t%d\t%d\n",num,num*2,num*3);
} /*End of loop A*/
//return 0;
}
No comments:
Post a Comment