Anonymous
With ans
Chris Ashley
Chris Ashley
Can someone please help me with this?
HeyMilkshake - 🇵🇹
Can someone please help me with this?
No! Do your own homework!! Edit: Be ashamed!
Anonymous
Asdew
Is it possible to initialize an integer in Hexa or binary base ?
Hexadecimal, yes, exactly as you showed, binary, depends on the compiler. GCC has it.
Serenity
Thanks a lot bro.
Asdew
And binary also works as you thought it would, if it works with your compiler.
Anonymous
IAMBACK👽
Anonymous
#include <stdio.h> int main() { int a= -1,b = -a; int x,y; x = (a> 0) && (b < 0) || (a< 0) && (b > 0); y = (a<= 0) || (b >= 0) && (a>= 0) || (b <= 0); printf("%d\n",x == y); return 0; }
x = (a > 0) && (b < 0) || (a < 0) && (b > 0); apply precedence and associativity (x = (((a > 0) && (b < 0)) || ((a < 0) && (b > 0)))); logical OR and AND guarantee left to right evaluation and short circuit evaluation (x = (false || (true && true))) (x = (false || true) (x = true) x is 1 do similarly for y. check if they are same
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.
Girish Kumar
I divided the number by 10 in each loop and checked the remainder
It it is a string you can't divide with 10. Iterate each character of the string in a loop and compare with Ascii value of either 1 or 0. If all characters satisfies it is a very binary no.
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
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");
the flow is wrong, for inputs like 102 the output will be: invalid input, please try againThe number is in a binary form try this int i = 0,remainder=0; int temp = num; int binary = 1; while (temp != 0) { remainder = temp % 10; if ((remainder != 0) && (remainder != 1)) { binary = 0; break; } temp /= 10; } if(binary) printf("The number is in a binary form"); else printf("invalid input, please try again");
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
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
😔
Mandelbröt
How to find the coordinate point among n points which make smallest counterclock angle with the given co ordinate
Francisco
Don't include bits/stdc++.h.
If he's doing competitive programming, it's fine
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
I had done with the convex hull ... And stored the vertices of layers of ploygons that can be made by n points ...m
Now the problem is i have to ask a query (a point (x,y) ) and check how many polygons have this point strictly inside it (not in the edge , nor in the vertices of any layer of a polygon )
Mandelbröt
Wait i ll show u my code
Mandelbröt
Yep ...i had figured it out ...and done
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
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
It's kind of confusing, I get a int number and it must consist of only 0's and 1's.
#include <stdio.h> #include <unistd.h> #define delay ... int main() { printf("Enter a number "); usleep(delay); printf("true"); }
Anonymous
For a computer all numbers contain only 0s and 1s
Anonymous
So the answer is always true
Anonymous
Anyway I was just joking