Nisha
Can you write a code
András
Anonymous
Using
Yep, that's missing too
András
int not Int and so on
Nisha
🆗
Anonymous
https://img.kingdev.nl/clion64_2019-11-07_14-26-49.png
Anonymous
I think the problem is that its a member function so there's the implicit this parameter, use it for the left hand side and the parameter as the right hand side
Anonymous
also, I think you're gonna have issues using that order with any of the standard algorithms and data structures
Anonymous
4. Please write a program in C or C++ that performs following function.
An array of 10 3-digit integers is given as {129, 099, 856, 738, 011, 222, 409, 177, 363, 600}. Please sort the integers according to the sum of their digits.
Snir
hello,I'm trying to sub this string by input length(if any character appear,print it only once)like this example.any suggestions?thank you.
Snir
Snir
length 2
Anonymous
MilkBeforeCereal
How to solve it
get each digit and store sum in another array
MilkBeforeCereal
while sorting sum array, sort original array too
Anonymous
https://img.kingdev.nl/NVIDIA%20Share_2019-11-07_14-53-20.png
Anonymous
so somehow my Map its size is 1
Anonymous
I do add multiple elements tho to the map, And the key should be correct
Anonymous
bool operator <(const MyVector &a) const {
return (a.x == this->x && a.y == this->y && a.z == this->z);
}
Ludovic 'Archivist'
Anonymous
?
Anonymous
@QNeko Yo need a operator like that for a map
Anonymous
because its not a strict weak order as required (its obviously reflexive)
Anonymous
you can try something like:
bool operator<(const MyVector &rhs) const {
return x < rhs.x && y < rhs.y && z < rhs.z;
}
Anonymous
Jay it has to match the coords not be less
Anonymous
x has to be the same as the passed vector x
Anonymous
what is Fibonacci series
Anonymous
fibnonachi numbers
Anonymous
Series
Anonymous
In c program
Anonymous
1, 1, 2, 3, 5, 8, 13, 21, 34
Kirk
1 1 2 3 5 8 13 21 34 55 89 144 etc
Anonymous
:/ why exactly do you think < should be the same as ==?
Anonymous
as < is less then
数学の恋人
Anonymous
Ok something weird
Anonymous
the vector passed to the function is awlays 0 0 0
Anonymous
Write c program to Perform swapping of two number without using third number
Anonymous
[2019-11-07 15:16:37.148] [info] comp: 0 0 0 - 15 15 10
[2019-11-07 15:16:37.148] [info] comp: 15 15 10 - 0 0 0
[2019-11-07 15:16:37.148] [info] setVec 15 15 10
[2019-11-07 15:16:37.148] [info] comp: 0 0 0 - 15 15 11
[2019-11-07 15:16:37.148] [info] comp: 15 15 11 - 0 0 0
Anonymous
the f
Anonymous
its because of your operator< but you're not listening lol
Anonymous
Ludovic 'Archivist'
Also, map will not work with that as being the same element in a map means !(a<b || b<a)
Ilya
Ludovic 'Archivist'
Ilya
Ludovic 'Archivist'
Rather, I would have that be
bool operator <(const MyVector &a) const {
if(this->x < a.x) return true;
else if(this->x == a.x)
{
if(this->y< a.y) return true;
else if(this->y == a.y)
{
if(this->z < a.z) return true;
}
}
return false;
}
Ludovic 'Archivist'
Anonymous
Hu?
Anonymous
But the issue aint that
Anonymous
the issue is the passed pos to the compare func
Anonymous
Its passing 0 0 0 to it
Anonymous
https://img.kingdev.nl/2019-11-07_15-38-16.png
数学の恋人
Anonymous
if the passed vector coords are 0 ofc compare fails
Pavel
Ludovic 'Archivist'
Ludovic 'Archivist'
If there's no overflow
Even if there is overflow if defined to be modulo arithmetic (the case in C and C++ for all unsigned integer types for example)
Anonymous
Hu?
The broken compare affects how the map behaves and is probably what is causing the (0, 0, 0) being passed to it too. Try a proper func for a second
Anonymous
hi
klimi
hi
Pavel
Yeah that's his problem
No, I think he's right. Even if it overflows it produces the correct result (if the variables have the same type).
Pavel
I mean the code is correct and Ludovic is right
Artöm
Vitaliy ◀️TriΔng3l▶️
Anonymous
🤔
Ludovic 'Archivist'
Vitaliy ◀️TriΔng3l▶️
This has a bug
What bug if you don't overload operator||?
Ludovic 'Archivist'
Ludovic 'Archivist'
Ludovic 'Archivist'