/* THIS IS A TURBO C++ CODE*/
/*the question is that their are some walkie talkies in their early
development stages a person buys some. these walkies talkies are beta
versions still under development. but he buys them anyways. now the promplem
arising in them is that though they are made to talk privately at
any range(1 to 1 no other can listen) but right now that is possible
at only a certain range.the twist is that if there are 3(number of walkies
is "n") walkies at given coordinates"x" and"y"(input by user and the range "r"
is given (input by user) and out off these three suppose walkie 1 is in
range of walkie 2 and walkie 1 is also in range with walkie 3 but walkie
2 and 3 are not in range with each other then the also they can privately
talk with each other through the number 2 walkie. we are to get the input
of the number of test cases "t" in which "n" "r" "x" and "y" can change
and also get the input for the coordinates range and number of walkies
and then calculate if ALL of them are capable of talking to each other
privately or not.*/
/*This code is a better version of what i gave in the compitition. but there
seams to be an error in it as it is not giving the desired out put. Please rectify if you have the time and dedication.
thanks.*/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
long double t,n,r,temp1,temp2,temp3,temp4[100];
long double x[15],y[15];
char ans;
cin>>t;
cin>>n;
cin>>r;
if(t>0 && t<11 && n>0 && n<11 && r>-30000 && r<30000)
{
for(int j=1;j<=t ;j++)
{
{
for(int i=1; i<=n; i++)
{
cin>>x[i];
cin>>y[i];
}
for(int k=1; k<=n; k++)
{
temp1=x[k+1]-x[k];
temp2=y[k+1]-y[k];
temp3=pow(temp2,2)+pow(temp1,2);
temp4[k]=pow(temp3,0.5);
if(temp4[k]<r || temp4[k]==r)
{
ans='Y';
}
else
{
ans='N';
}
}
cout<<ans;
}
}
}
else
cout<<"You got it wrong again darling ";
getch();
}
|
Here the code.... I am a c++ cbse board (India) student studying in class xii and I will also discuss with my teacher. But will be grateful if any of you can help me out.
Cheers
Katyayn