All pastes #1819 Raw Edit

crapass

public c v1 · immutable
#1819 ·published 2004-10-31 17:07 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>void fill(char des[20][40], int x, int y, char c){        if(des[x][y]==' ') des[x][y]=c;        if(des[x][y-1]==' ') fill(des,x,y-1,c);        if(des[x-1][y]==' ') fill(des,x-1,y,c);        if(des[x][y+1]==' ') fill(des,x,y+1,c);        if(des[x+1][y]==' ') fill(des,x+1,y,c);}int main(void){        int line,column,i,j;        char charsel;        char drawing[20][40];        FILE *filein=NULL,*fileout=NULL;        filein=fopen("in","rt");        fileout=fopen("out","wt");        for(i=0;i<20;i++)        {                for(j=0;j<40;j++)                fscanf(filein,"%c",&drawing[i][j]);        }        printf("Insert line and column number for the start position\n");        scanf("%d %d",&line,&column);        getchar();        printf("Insert the fill character (must not be an empty space)\n");        scanf("%c",&charsel);        fill(drawing,line,column,charsel);        for(i=0;i<20;i++)        {                for(j=0;j<40;j++)                fprintf(fileout, "%c", drawing[i][j]);        };        printf("Result has been spewed to file named 'out'");        fclose(filein);        fclose(fileout);        getchar();        return 0;}