Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///BISMILLAHIR-RAHMANIR-RAHIM
- #include <stdio.h>
- #include <string.h>
- int main()
- {
- int test;
- scanf("%d", &test);
- char t[105], s[105];
- int i, len, flag, j;
- while(test--){
- scanf("%s", &t);
- flag = 0;
- len = strlen(t);
- for(i = 1; i < len; i++){
- if(t[i] != t[0]){
- flag = 1;
- break;
- }
- }
- if(flag){
- s[0] = t[0];
- for(i = 1, j= 1; i < len; i++){
- if(t[i] == t[i - 1]){
- if(t[i] == '0') s[j] = '1';
- else s[j] = '0';
- j++;
- s[j] = t[i];
- j++;
- }
- else{
- s[j] = t[i];
- j++;
- }
- }
- s[j] = '\0';
- printf("%s\n", s);
- }
- else{
- printf("%s\n", t);
- }
- }
- return 0;
- }
- ///ALHAMDULILLAH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement