Anonymous
With ans
Anmol
Dima
Chris Ashley
Chris Ashley
Can someone please help me with this?
Anonymous
Serenity
Thanks a lot bro.
Asdew
And binary also works as you thought it would, if it works with your compiler.
Anonymous
IAMBACK👽
Anonymous
Anonymous
That exactly what I meant
Serenity
Can anyone give me a hint on how to write a function that gets a string and returns true iff all its elements are binary numbers
Serenity
Hmm sorry
Serenity
yes
Serenity
I divided the number by 10 in each loop and checked the remainder
Serenity
but it doesn't work with long numbers
Serenity
Oh sorry
Serenity
it's not a string, it's a regular int number
Serenity
It's kind of confusing, I get a int number and it must consist of only 0's and 1's.
Serenity
I created a loop and divided the number by 10 at each time (checked the remainder simultaneously)
Serenity
But it doesn't work with numbers greater than 1024 as far as I know
Serenity
Yes , that's what I have done and it worked with just small numbers.
Serenity
I'll write it again and show you
Serenity
int i = 0,remainder=0;
int temp = num;
while (temp != 0)
{
remainder = temp % 10;
if ((remainder != 0) && (remainder != 1))
{
printf("invalid input, please try again");
}
temp /= 10;
}
printf("The number is in a binary form");
Serenity
It works with small numbers but if set larger numbers I get an incorrect answer.
Anonymous
Anonymous
Anonymous
I, ll pass
Anonymous
#include<string>
Bool checkbinary(long long n)
{
Std::string str=std::to_string(n);
For(int i=0;i<str. Length();i++)
{
if(str[i]=='1'||str[i]=='0')
{
Return false;
Break;
}
}
Return true;
}
Anonymous
@SNSNSNSNY9
Anonymous
No need of the break
Girish Kumar
I wrote push() function for Circular double linked list with Sentinel node and it worked fine. The full code is in below link. Same like append() function will also work. But I'm missing exact logic somewhere.
https://paste.ubuntu.com/p/mgPjVvKCxH/
Output: 100 99 3 2 1
Anonymous
Thanks a lot Rose.
Mandelbröt
Hey can anyone help me to implement the convex hull to find the layers of polygons (the polygons are non intersecting as well non overlapping ) . No need that each and every point of n have to belong with a polygon
Anonymous
Mandelbröt
Mandelbröt
I m stuck with some situations ....
Mandelbröt
Just like ....lets say for every polygon i have to check the lowest ordinate and then traverse through all ordinates to build a polygon ...but after creating a polygon i have to make the ordinates vlear that already used
Anonymous
Cn u show the c0de
Mandelbröt
Yep i m sending it wait ....
MᏫᎻᎯᎷᎷᎬᎠ
.
Mandelbröt
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
int tc;
cin>>tc;
while(tc--){
int n,queries,i,temp,temp1,min_y=0,min_x=0;
cin>>n>>queries;
vector<pair<lli,lli> >points,temp_v;
vector<vector<pair<lli,lli> > >v;
for(i=0;i<n;i++){
cin>>temp>>temp1;
points.push_back(make_pair(temp,tem3p1));
}
while(points.size()>2){
temp_y=points[0].second;
temp_x=points[0].first;
for(i=1;i<points.size();i++){
if(temp_y>points[i].second){
temp_y=points[i].second;
temp_x=points[i].first;
}
else if(temp_y==points[i].second){
if(temp_x>points[i].first){
temp_x=points[i].first;
}
}
}
}
}
return 0;
}
Mandelbröt
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
int tc;
cin>>tc;
while(tc--){
int n,queries,i,temp,temp1,min_y=0,min_x=0;
cin>>n>>queries;
vector<pair<lli,lli> >points,temp_v;
vector<vector<pair<lli,lli> > >v;
for(i=0;i<n;i++){
cin>>temp>>temp1;
points.push_back(make_pair(temp,tem3p1));
}
while(points.size()>2){
temp_y=points[0].second;
temp_x=points[0].first;
for(i=1;i<points.size();i++){
if(temp_y>points[i].second){
temp_y=points[i].second;
temp_x=points[i].first;
}
else if(temp_y==points[i].second){
if(temp_x>points[i].first){
temp_x=points[i].first;
}
}
}
}
}
return 0;
}
Sticked after the finding the lowest ordinate ...
Mandelbröt
😔
Mandelbröt
How to find the coordinate point among n points which make smallest counterclock angle with the given co ordinate
Asdew
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
int tc;
cin>>tc;
while(tc--){
int n,queries,i,temp,temp1,min_y=0,min_x=0;
cin>>n>>queries;
vector<pair<lli,lli> >points,temp_v;
vector<vector<pair<lli,lli> > >v;
for(i=0;i<n;i++){
cin>>temp>>temp1;
points.push_back(make_pair(temp,tem3p1));
}
while(points.size()>2){
temp_y=points[0].second;
temp_x=points[0].first;
for(i=1;i<points.size();i++){
if(temp_y>points[i].second){
temp_y=points[i].second;
temp_x=points[i].first;
}
else if(temp_y==points[i].second){
if(temp_x>points[i].first){
temp_x=points[i].first;
}
}
}
}
}
return 0;
}
Don't include bits/stdc++.h.
Mandelbröt
Mandelbröt
Anonymous
hi, I'm looking for a pc version of an application where I can learn c++, can anyone help me out?
Mandelbröt
Any idea how to check a point (x,y) lies inside/on the edge/on the vertices of a polygon (polygon have the vertices)
Mandelbröt
I had done with the convex hull ...
And stored the vertices of layers of ploygons that can be made by n points ...m
Mandelbröt
Wait i ll show u my code
Mandelbröt
Yep ...i had figured it out ...and done
Mandelbröt
Mandelbröt
Mandelbröt
Any resource for the implementation of this concept !!?
Mandelbröt
Or there any ...short func or trick !!? ...my code already reached 150 lines 😅
Mandelbröt
https://stackoverflow.com/questions/7050186/find-if-point-lays-on-line-segment/7050238#:~:text=Find%20the%20distance%20of%20point,on%20the%20line%20segment%20AB.&text=First%20take%20the%20cross%20product,then%20it%20will%20be%200.
Mandelbröt
Thanx ...i got it
Mandelbröt
Yep ...but i thought if i can check it for every segment of a polygon then ...i can figure out the layer in whic it lies in the boundary ...so before that polygon ... I got all the number of polygons which have the point strictly inside it
Mandelbröt
The problem is to find the number of polygons which have the point strictly inside it ...
Polygons must be made by the n points (layers of polygons) and no two polygon should intersect or overlap with each other
Mandelbröt
Mandelbröt
Yep thats rit ...
But it just ruin my tym complx 😢
Mandelbröt
Yep i have to implement the semicircle one ...
Mandelbröt
Thnx so much :)
@.!
So sorry for bothering, is there a way for changing pdf file to excel ??
@.!
Any suggestions??
Mandelbröt
Tried it
Anonymous
Anonymous
For a computer all numbers contain only 0s and 1s
Anonymous
So the answer is always true
Anonymous
Anyway I was just joking