Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.4 kB
4
Indexable
Never
#include<stdio.h>

int main(){

    int R,C,T;
    int i,j,k,m,t;
    int Fir_i[105],Fir_j[105];
    char class[105][105];

    scanf("%d %d %d",&R,&C,&T);

    for(i=1;i<R+1;i++){
        for(j=1;j<C+1;j++){
            if(j!=C) scanf(" %c",&class[i][j]);
            else scanf("%c",&class[i][C]);
        }
    }

    if(T!=0){

        for(t=1;t<=T;t++){
            k=1;

            for(i=1;i<R+1;i++){
                for(j=1;j<C+1;j++){

                    if(class[i][j]=='F'){
                        Fir_i[k]=i;
                        Fir_j[k]=j;
                        k++;
                    }
                }
            }

            //printf("%d %d",Fir_i[2],Fir_j[2]);

            for(i=1;i<k;i++){
                //printf("in");
                if(class[Fir_i[i]+1][Fir_j[i]]=='C')class[Fir_i[i]+1][Fir_j[i]]='F';
                if(class[Fir_i[i]-1][Fir_j[i]]=='C')class[Fir_i[i]-1][Fir_j[i]]='F';
                if(class[Fir_i[i]][Fir_j[i]+1]=='C')class[Fir_i[i]][Fir_j[i]+1]='F';
                if(class[Fir_i[i]][Fir_j[i]-1]=='C')class[Fir_i[i]][Fir_j[i]-1]='F';
            }
        }
    }
    
    for(i=1;i<R+1;i++){
        for(j=1;j<C+1;j++){
            if(j!=C) printf("%c",class[i][j]);
            else printf("%c\n",class[i][C]);
        }
    } 

    return 0;
}