+ 1

How to reverse the input in c++?

A

11th Sep 2018, 1:31 PM
Abdul Wahab
Abdul Wahab - avatar
4 Antworten
+ 7
I am considering it as int, so int num = 1234, reversed = 0; while (num > 0) { reversed = (num % 10) + (reversed * 10) num /= 10 ; }
11th Sep 2018, 6:26 PM
blACk sh4d0w
blACk sh4d0w - avatar
+ 5
what is the data type of your input? integer, string, array or anything else?
11th Sep 2018, 6:18 PM
blACk sh4d0w
blACk sh4d0w - avatar
0
depending on input you could convert it to an array and reverse it that way.
11th Sep 2018, 2:37 PM
Jason Hoffman
Jason Hoffman - avatar
0
1234 type
11th Sep 2018, 6:23 PM
Abdul Wahab
Abdul Wahab - avatar