#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
#include<string>
//理解题意,最小周期:不是1就是2,;如果是1的话,那么字符串就是全1或全0;反之,如果不是,那么如果想让字符串周期为2的话,形式只有01010101,或者101010这种形式
int main()
{
int t;
cin >> t;
string data;
for(int i = 0; i < t; i ++)
{
cin >> data;
int len = data.length();
int h;
for(h = 1;h < len;h ++)//判断周期是否为1
{
if(data[h - 1] == data[h])
continue;
else
break;
}
if(h == len)
cout << data << '\n';
else//构造1010形式的
{
for(int j = 0; j < len; j ++)
{
if(data[j] == '1' && data[j + 1] != '0')
cout <<"10";
else if(data[j] == '0' && data[j - 1] != '1')
cout << "10";
else
cout << data[j];
}
cout << '\n';
}
}
return 0;
}
02-05
07-17
548
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-18
308
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交