Aasif
So, you can input a string and then convert it to integer. And check if it's not empty.
Aasif
Because an integer will never be "\0"
Sai Meghana
a string only takes until space right?
Sai Meghana
the next input will be in the next line
Aasif
a string only takes until space right?
A string takes input on line break as well.
Aasif
https://stackoverflow.com/questions/9235296/how-to-detect-empty-lines-while-reading-from-istream-object-in-c
Aasif
okay, but is there anything wrong with what ive done here? just curious..
Yes, an integer will never be '\0' and hence it is getting stuck in an infinite loop
Sai Meghana
is there any way to check if its the last input as an integer?
Aasif
is there any way to check if its the last input as an integer?
I don't think so, you could check it in a string.
Aasif
And then you could convert that string into an integer.
Sai Meghana
Sai Meghana
mmm
Aasif
for the calling of check part
Are you beginning competitive programming? If you are, then leetcode is good.
Sai Meghana
okay, ill try that. but for now, to check the basic working of the code ill just use one input...
Sai Meghana
int check(int n) { if (n>=0 && n<7) return n; return floor(check(n/2))+floor(check(n/3))+floor(check(n/4)); }
Sai Meghana
can i do this? for 0<n<7?
Aasif
can i do this? for 0<n<7?
Why do you want to do that?
Sai Meghana
because if the given number is lesser than that, the program would further divide that... and the dollars would become less.. right?
Sai Meghana
say 6 is input.. it would become 3,2,0 then you'd get 5 dollars.. but if 6 was untouched.. you'gd get 6
Sai Meghana
oh right
Sai Meghana
what if.. input is 3
Sai Meghana
then it'd be 1, 1, 0
Aasif
what if.. input is 3
There the answer would be 2 for input 3
Sai Meghana
if input is 4 then both methods give 4 itself..
Sai Meghana
so i should give that for 0<n❤️
Sai Meghana
0<n< 3
Aasif
Aasif
0<n< 3
Why do you want to do that?
Aasif
Oh I get it. Sorry.
Sai Meghana
then it'd be 1, 1, 0
so the program doesnt breakdown 3 to 1,1,0... id just put if (n>=0 && n<4) return n;
Sai Meghana
they want us to print the maximum possible
Sai Meghana
dollars
Aasif
Yes
Aasif
But you can't exchange one gold coin with 3 written on it for 3, dollars.
Sai Meghana
so it shouldnt be broken down because if its broken we get 2 dollars instead of 3
Aasif
so it shouldnt be broken down because if its broken we get 2 dollars instead of 3
However, if you break it, then you get two gold coins, which could each be exchanged for a dollar.
Sai Meghana
then how's they change coin 2 to $2 directly in the last line?
Aasif
then how's they change coin 2 to $2 directly in the last line?
I'm sorry, I'll read the question properly.
Sai Meghana
are you implying that gold coins are different from other coins?
Aasif
are you implying that gold coins are different from other coins?
No. I'm sorry, I'm reading it again.
Aasif
You could check for n and n/2, n/3, n/4
Aasif
Return max(n, check(n/2)+check(n/3)+check(n/4)) is what I mean.
Aasif
And for n<4 return n
Laxmikant
Please tell any esey way to learning programming
Dima
Dima
0. just 1. do it
I_Interface
> easy way > learn programming > 😂😂😂😂😂😂
I_Interface
python
only C++, only hardcore
Laxmikant
Python is really esay
Андрей
Dima
only C++, only hardcore
you said the easy way, just like for monkeys
Андрей
Python is really esay
but first I think it's better to learn English, it's easy too )
I_Interface
I_Interface
So rude
agreed
I_Interface
Dima is rude
Андрей
Dima
js and python is for monkeys, this is what
Андрей
js and python is for monkeys, this is what
c++ for long-living monkeys :D
Dima
Exactly
Laxmikant
js and python is for monkeys, this is what