Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- char v[30];
- int main()
- {
- int i,j,n,mut;
- char c;
- c=fgetc(stdin);
- if(c=='-')
- mut++;
- i=0;
- n=0;
- mut=0;
- while(c!='\n')
- {
- v[i]=c;
- c=fgetc(stdin);
- if(c=='-')
- mut++;
- n++;
- i++;
- }
- i=0;
- while(v[i]!='O' && v[i]!='X')
- i++;
- if(v[i]=='O')
- {
- j=i;
- while(v[j]!='X')
- j++;
- while(v[i]!='-')
- i++;
- if(i<j)
- {
- v[i]='X';
- v[j]='-';
- }
- else
- {
- printf("a");
- printf("%d",mut);
- if(mut%2==0)
- {
- printf("a");
- i=1;
- while(v[i]!='O')
- i++;
- if(v[i+1]=='X')
- {
- while(v[i]=='O' && v[i]=='X')
- i++;
- while(v[i]!='O' && i<n)
- i++;
- if(v[i]!='O')
- {
- i=1;
- while(v[i]!='O')
- i++;
- v[i]='-';
- v[i-1]='O';
- }
- else
- {
- v[i]='-';
- v[i-1]='O';
- }
- }
- }
- else
- {
- //printf("a");
- i=2;
- while(v[i]!='O')
- i++;
- if(v[i+1]=='X')
- {
- while(v[i]=='O' && v[i]=='X')
- i++;
- while(v[i]!='O' && i<n)
- i++;
- if(v[i]!='O')
- {
- i=2;
- while(v[i]!='O')
- i++;
- v[i]='-';
- v[i-2]='O';
- }
- else
- {
- v[i]='-';
- v[i-2]='O';
- }
- }
- }
- }
- }
- else
- {
- v[i]='-';
- }
- for(i=0;i<n;i++)
- fputc(v[i], stdout);
- fprintf(stdout, "\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement