"666" is a network language, probably is a very powerful person, we admire mean. Recently spawned another number "9", which means "turned 6," is too much meaning. If you think this is the highest level of powerful, you're wrong - currently the highest level are the number "27", because it was 3 "9"!
This question will ask you to write a program, those obsolete, only with a series of "6666 ...... 6" expressed admiration sentence, translated into the latest high-level expression.
Input formats:
Given input sentence in a row, i.e., a non-empty string by not more than 1,000 letters, numbers and spaces, ends with a carriage return.
Output formats:
Scan input sentence from left to right: if the sentence has more than three consecutive 6, this string will be replaced by a continuous 6 9; if there are more than 9 consecutive 6, this string will be replaced by a continuous 6 27. Other content will not be affected, as it is output.
Sample input:
it is so 666 really 6666 what else can I say 6666666666
Sample output:
it is so 666 really 9 what else can I say 27
There are a few statistics to meet six, not six outputs.
After completion of the statistical 6 If the conversion is converted, does not convert, then put back some six output intact ~.
#include<iostream>
using namespace std;
int main(){
string s;
getline(cin,s);
int i=0,count6=0;
while(i<s.size()){
if(s[i]!='6')cout<<s[i++];
else {
for(count6=0;s[i]=='6'&&i<s.size();i++,count6++);
if(count6>9)cout<<27;
else if(count6>3)cout<<9;
else while(count6-->0)cout<<6;
}
}
return 0;
}