Mat
so int t {n};
Mat
Adn good luck with it
Zeus
But.. how am I supposed to retrieve the value of n once the loop exists
#>|~|√-\®®¥[∆]
But.. how am I supposed to retrieve the value of n once the loop exists
See it is intialised with int I hope u can return
Mat
In do_while loop, use z In for loop, use z and rest
Zeus
What?
U see.. I used while loop to detect how many digits am entering right.. but eventually the value of n is 0 and loop exists... Now I need the default value of number to reverse it..
Mat
Don't use n inside loops
Zeus
Don't use n inside loops
Alright.. it's working thnx man😁
数学の恋人
Hey everyone I'm having one little problem here
数学の恋人
The problem is described here: https://www.hackerrank.com/challenges/compare-the-triplets/problem
数学の恋人
And the solution I came up is this: https://raw.githubusercontent.com/redhackthings/Code_Practice/master/Compare_Triplets/compare_triplets.cpp
数学の恋人
But don't Know why Abort is called when the score should be 0 0
olli
Why? I gave i<=2 right?
Yes, but a[1][2] reserves space for 1*2 ints
olli
You probably wanted a[2][3] ?
数学の恋人
Yes, but a[1][2] reserves space for 1*2 ints
Oh, okay. But everything is fine for anyother case
数学の恋人
You probably wanted a[2][3] ?
Okay I'll try this
数学の恋人
olli
Oh, okay. But everything is fine for anyother case
Accessing array elements out of bounds is undefined. It may but is not required to work.
数学の恋人
Actually I'm new to C++ 14 so didn't know the proper working, thanks for helping me out
数学の恋人
I found it strange that while defining the array if I do this int a[1,2] then the compiler gives error
数学の恋人
That is no valid c or c++ syntax.
But I learnt that way and it used to work.
olli
Is it old syntax?
It has never been iso c or c++ conformant. I only know this syntax from C#
数学の恋人
It has never been iso c or c++ conformant. I only know this syntax from C#
Oh actually I learnt C++ from some old book ( time when people used Turbo C++ or Borland C++)
olli
Oh actually I learnt C++ from some old book ( time when people used Turbo C++ or Borland C++)
Its possible they have added it as language extensions, I never used them though
数学の恋人
That is no valid c or c++ syntax.
Oh wait you're correct
数学の恋人
Even I have not used it that way in C++
数学の恋人
Sorry my bad
数学の恋人
I just forgot
olli
Oh okay, no problem :)
数学の恋人
Yes, but a[1][2] reserves space for 1*2 ints
does a[0][0] won't exist if if initialize it like a[1][2]?
olli
does a[0][0] won't exist if if initialize it like a[1][2]?
When you have int a[1][2]; you can access a[0][0] and a[0][1] I hope this answers your question, not sure I got it
olli
You can always access each dimension at index 0, since each dimension is required to be at least of size 1
klimi
Have I?
Alignant
School sport event... For week
I hope you win this shit~
olli
No, promotions are not allowed
olli
What is this group about?
Anonymous
Hello guys
Mat
lol no
Dima
lol only later I did realize that @programminginc (this group) is read as “programming in c”, not “Programming Inc.”
Dima
lol
Anonymous
Hi! How come %10 returns the last digit in a number? For instance 597%10 returns 7.
Alignant
How did I guess? :D
Mat
A%B returns the rest of the division A/B
Anonymous
Ohh can't post SO links here?
Mat
If B = 10, it's obvious it will return the last digit
Mat
Ohh can't post SO links here?
No links if you're a new member
Mat
It doesn't
That was misleading :/ sorry
Anonymous
Ohhh, so in my case, 597%10 = 7 because 597/10 = 59.7 @Occupato ?
Anonymous
Ohh so this is modulus operator, not something in C++ to return the last character right?
Zeus
I just realised am a very bad coder😂😂
Anonymous
☺ Newbie here, teaching myself C++ and solving small problems.
Anonymous
Got it now @Occupato. TY so much!
Mat
No problem :)
Mat
Zeus
It's obv an int
O then 597/10 will be 59.. not 59.7
Zeus
😅
Zeus
I meant.. if he declared 597 as an integer or float😅
Zeus
Yes but u can also store numbers without decimal..
Mat
597 is a literal, thus is only an int :P