#include<stdio.h>
#include<conio.h>
#define SIZE 100
struct nmbr
{
int fp[2];
int fpas[2];
};
void main()
{
struct nmbr n[SIZE],*n1,*n2;
clrscr();
int flag = 0,i,j,num,x=0;
printf("\n Enter any number : ");
scanf("%d",&num);
for(i=1;i<=num/2;i++)
{
if(num%i==0)
{
n[x].fp[0] = num/i ;
n[x].fp[1] = i ;
n[x].fpas[0] = n[x].fp[0] + n[x].fp[1] ;
n[x].fpas[1] = n[x].fp[0] - n[x].fp[1] ;
x++;
}
}
for(i=0;i<x;i++)
{
n1 = n;
n2 = n+i;
for(j=0;j<x;j++)
{
if( n2->fpas[1]==(n1+j)->fpas[0] || n2->fpas[0]==(n1+j)->fpas[1] )
{
flag = 1;
break;
}
n1 ++;
}
}
if(flag == 1)
printf("\n\n %d is a nasty number !! ",num);
else
printf("\n\n %d isn't a nasty number !! ",num);
getch();
}
#include<conio.h>
#define SIZE 100
struct nmbr
{
int fp[2];
int fpas[2];
};
void main()
{
struct nmbr n[SIZE],*n1,*n2;
clrscr();
int flag = 0,i,j,num,x=0;
printf("\n Enter any number : ");
scanf("%d",&num);
for(i=1;i<=num/2;i++)
{
if(num%i==0)
{
n[x].fp[0] = num/i ;
n[x].fp[1] = i ;
n[x].fpas[0] = n[x].fp[0] + n[x].fp[1] ;
n[x].fpas[1] = n[x].fp[0] - n[x].fp[1] ;
x++;
}
}
for(i=0;i<x;i++)
{
n1 = n;
n2 = n+i;
for(j=0;j<x;j++)
{
if( n2->fpas[1]==(n1+j)->fpas[0] || n2->fpas[0]==(n1+j)->fpas[1] )
{
flag = 1;
break;
}
n1 ++;
}
}
if(flag == 1)
printf("\n\n %d is a nasty number !! ",num);
else
printf("\n\n %d isn't a nasty number !! ",num);
getch();
}
No comments:
Post a Comment