Created
November 18, 2015 15:50
-
-
Save jiunbae/6887f05eafbd9838971f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <string> | |
| #include <fstream> | |
| using namespace std; | |
| int main(int argc, char * argv[]) | |
| { | |
| ifstream in("self_introduce_number.in"); | |
| ofstream out("self_introduce_number.out"); | |
| int test; in >> test; | |
| //int test; cin >> test; | |
| while (test--) | |
| { | |
| string str; in >> str; str += ' '; | |
| //string str; cin >> str; str += ' '; | |
| if(str == "22 ") | |
| { | |
| out << "2" << endl; | |
| continue; | |
| } | |
| int fix = 0, len = 0, max_len = 0, max = 3; | |
| for (char idx : str) | |
| { | |
| idx -= '0'; | |
| if (max < idx) | |
| max = idx; | |
| if (fix - idx) | |
| { | |
| if (max_len < len) | |
| max_len = len; | |
| fix = idx; | |
| len = 1; | |
| } | |
| else | |
| len++; | |
| } | |
| out << (max_len > max ? max_len : max) << endl; | |
| //cout << (max_len > max ? max_len : max) << endl; | |
| } | |
| in.close(); | |
| out.close(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment