#include <iostream.h>
#include <conio.h>
using namespace std;
using std::cout; using std::cin;
struct rabbit
{
int x;
int y;
};
bool sameline(rabbit r1,rabbit r2,rabbit r3)
{
float r1r2=(float)(r1.x-r2.x)/(r1.y-r2.y);
float r2r3=(float)(r3.x-r2.x)/(r3.y-r2.y);
float r1r3=(float)(r1.x-r3.x)/(r1.y-r3.y);
if((r1r2==r2r3)&&(r2r3==r1r3))
{
return true;
}
else return false;
}//end of sameline
int main()
{
enum {x,y};
cout<<"\nPlease enter number of rabbits: ";
int number=0;
cin>>number;
rabbit array[256];
for(int i=0;i<number;i++)
{
cout<<"\n\n\nPlease enter x_{"<<i+1<<"}: ";
cin>>array[i].x;
cout<<"\nPlease enter y_{"<<i+1<<"}: ";
cin>>array[i].y;
}
int max =0,thisone=0;
for(int i=0;i<number;i++)
{
for(int j=i+1;j<number;j++)
{
thisone = 2;
for(int n=0;n<number;n++)
{
if(sameline(array[i],array[j],array[n])&&(n!=j)&&(n!=i))
{
thisone++;
}//end of if
}//end of third for
if(thisone>max) max=thisone;
}//end of second for
}//end of first for
cout<<"\n Maximum number of rabbits to be killed is : "<<max;
getch();
return 0;
}//end of main
#include <alloc.h>
using namespace std;
using std::cout; using std::cin;
#include <iostream.h>
#include <conio.h>
using namespace std;
using std::cout; using std::cin;
struct rabbit
{
int x;
int y;
};
bool sameline(rabbit r1,rabbit r2,rabbit r3)
{
bool one=false,two=false,three=false;
if((r1.y-r2.y)==0) one= true;
if((r2.y-r3.y)==0) two= true;
if((r1.y-r3.y)==0) three= true;
if(one&&two&&three) return true;
else
{
float r1r2=(float)(r1.x-r2.x)/(r1.y-r2.y);
float r2r3=(float)(r3.x-r2.x)/(r3.y-r2.y);
float r1r3=(float)(r1.x-r3.x)/(r1.y-r3.y);
if((r1r2==r2r3)&&(r2r3==r1r3))
{
return true;
}
else return false;
}
}//end of sameline
int main()
{
enum {x,y};
cout<<"\nPlease enter number of rabbits: ";
int number=0;
cin>>number;
if(number<1)
{
cout<<"\nInvalid number of rabbits!!";
getch();
exit(0);
}
rabbit array[256];
for(int i=0;i<number;i++)
{
cout<<"\n\n\nPlease enter x_{"<<i+1<<"}: ";
cin>>array[I].x;
cout<<"\nPlease enter y_{"<<i+1<<"}: ";
cin>>array[I].y;
}
int max =1,thisone=0;
for(int i=0;i<number;i++)
{
for(int j=i+1;j<number;j++)
{
thisone = 2;
for(int n=0;n<number;n++)
{
if(sameline(array[I],array[j],array[n])&&(n!=j)&&(n!=i))
{
thisone++;
}//end of if
}//end of third for
if(thisone>max) max=thisone;
}//end of second for
}//end of first for
cout<<"\n Maximum number of rabbits to be killed is : "<<max;
getch();
return 0;
}//end of main
#include<iostream.h>
#include<conio.h>
#include<math.h>
main()
{
const int N=256;
int A[N],n,i,x;
cout<<"enter n:";
cin>>n;
x=9*pow(10,n-1);
A[0]=pow(10,n-1);
for(i=1;i<x;i++)
A[I]=A[i-1]+1;
for(i=0;i<x;i++)
cout<<A[I]<<endl;
getch();
}
#include <iostream.h>
#include <stdio.h>
int main()
{
int n=0;
printf("Please enter n:");
scanf("%d",&n);
int *x=(int *)malloc(sizeof(int)*n);
return 0;
}
#include<iostream.h>
#include<conio.h>
#include<math.h>
main()
{
const int N=256;
int A[N],n,i,x;
cout<<"enter n:";
cin>>n;
x=9*pow(10,n-1);
A[0]=pow(10,n-1);
for(i=1;i<x;i++)
A[I]=A[i-1]+1;
for(i=0;i<x;i++)
cout<<A[I]<<endl;
getch();
}
#include <iostream.h>
#include <stdio.h>
int main()
{
int n=0;
printf("Please enter n:");
scanf("%d",&n);
int *x=(int *)malloc(sizeof(int)*n);
return 0;
}
#include <iostream.h>
#include <stdio.h>
int main()
{
int n=0;
printf("Please enter n:");
scanf("%d",&n);
int *x=(int *)malloc(sizeof(int)*n);
return 0;
}