Last active
November 5, 2019 08:36
-
-
Save pinglunliao/68d2400ac902bfb501f4 to your computer and use it in GitHub Desktop.
a038: 數字翻轉 FYI: https://yunlinsong.blogspot.com/2016/02/blog-post_10.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <sstream> | |
using namespace std; | |
int main() | |
{ | |
string s; | |
while(cin >> s) | |
{ | |
short len = s.length(); | |
bool hasZero = true; | |
for(short i = len - 1; i >= 0; i--) | |
{ | |
if( s[i] != '0' ) | |
{ | |
hasZero = false; | |
} | |
if( !hasZero ) | |
cout << s[i]; | |
} | |
cout << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment