Skip to content

Instantly share code, notes, and snippets.

@jiunbae
Created November 18, 2015 15:50
Show Gist options
  • Save jiunbae/6887f05eafbd9838971f to your computer and use it in GitHub Desktop.
Save jiunbae/6887f05eafbd9838971f to your computer and use it in GitHub Desktop.
#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