# Team programming TIANTI competition - exercise set L1-058 6 turned (15 points)

"666" is a kind of Internet term, which means that someone is very powerful and we admire him very much. Recently, another number "9" has been derived, which means "6 times over". It's really too powerful. If you think this is the highest level of power, you are wrong - the current highest level is the number "27", because this is three "9"!

This question asks you to write the program, will those obsolete, will only use a series of "6666 6 "to express admiration and translate it into the latest advanced expression.

Input format:
Input gives a sentence in a line, that is, a non empty string consisting of no more than 1000 English letters, numbers and spaces, ending with a carriage return.

Output format:
Scan the input sentence from left to right: if there are more than 3 consecutive 6 in the sentence, replace the consecutive 6 with 9; but if there are more than 9 consecutive 6, replace the consecutive 6 with 27. Other content will not be affected and will be output as is.

Input example:
it is so 666 really 6666 what else can I say 6666666666
Output example:
it is so 666 really 9 what else can I say 27

Problem solving: this problem is not difficult, don't think about it. It's good to judge four situations directly in the for loop. You must add the limit that the next element is not 6, otherwise you will output more things. Also, after each output, the count timer will be reset. To facilitate the next calculation.
Complex method: directly when 6 is greater than 3, use counter count to operate the code to be printed. But problems often arise. It's not as straightforward as the solution.

```#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

char ch,c;
int main()
{
int i=0,j=0;
int count=0;
while((c=getchar())!='\n')
{
ch[i++]=c;
}
for(i=0;ch[i]!='\0';i++)
{
if(ch[i]=='6')
count++;
if(count>9&&ch[i+1]!='6')
{
cout<<27;
count=0;
}
if(count>3&&count<=9&&ch[i+1]!='6')
{
cout<<9;
count=0;
}
if(count<=3&&ch[i+1]!='6')
{
for(j=0;j<count;j++)
cout<<6;
count=0;
}

if(ch[i]!='6')
cout<<ch[i];
}
return 0;
}

```

The following is the complex solution I wrote. There will be some mistakes. No changes have been found....

```#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

char ch,c;
int main()
{
int i=0,j=0,k,n,num;
int count=0;
while((c=getchar())!='\n')
{
ch[i++]=c;
}
for(i=0;ch[i]!='\0';i++)
{
count=0;num=0;
while(ch[j]!='\0')
{
if(ch[j]=='6')
count++;
j++;
if(count<=3&&ch[j]!='6')
{
num=1;
break;
}
if(count>3&&ch[j]!='6')
{
break;
}
}

if(num)
{
for(k=i;k<=j;k++)
{
cout<<ch[k];
}
}
else
{
//cout<<"hello";
for(k=i;k<j-count;k++)
{
if(k==i)
cout<<" ";
cout<<ch[k];
}
}

if(count>9)
cout<<27<<" ";
if(count<=9&&count>3)
cout<<9<<" ";

i=j;
}
//cout<<"\b"<<endl;
return 0;
}

```

Added by Tonata on Thu, 28 Nov 2019 21:38:11 +0200