Moss Code

Codequiry possesses an advanced plagiarism detection solution to perform a Moss Code plagiarism check. Our engine was designed to be able to detect up to 11 billion different web sources for evidence of plagiarism. We appreciate your visit to our website for more information#include <stdio.h>
#include<stdlib.h>
#include<string.h>

int global_res=0;

char up(int x,int y,char* ptr,int col){
return (ptr+(col(y-1))+x);
}
char down(int x,int y,char* ptr,int col){
return (ptr+(col(y+1))+x);
}
char right(int x,int y,char* ptr,int col){
return (ptr+(coly)+x+1);
}
char left(int x,int y,char* ptr,int col){
return (ptr+(coly)+x-1);
}

void printing(char* ptr,int rows,int col){
int i;
for (i=0;i<rows;i++){
printf("%.s",col,ptr+i(col));
}
}
int path_exist(char* ptr,int row,int col,int x,int y){

​​​​*(ptr+(col*y)+x)='.';
​​​​if ((right(x,y,ptr,col)=='X' || right(x,y,ptr,col)=='.') && (up(x,y,ptr,col)=='X' || up(x,y,ptr,col)=='.') && (down(x,y,ptr,col)=='X' || down(x,y,ptr,col)=='.') && (left(x,y,ptr,col)=='X' || left(x,y,ptr,col)=='.') ){
​​​​
​​​​    return 0;
​​​​}
​​​​if ((x==col || x==0 || y==0 || y==row) && ((*(ptr+(col*y)+x))!='X')){
​​​​ 
​​​​    global_res=1;
​​​​    return 1;
​​​​}
​​​​if (*(ptr+(col*y)+x)=='X'){
​​​​    
​​​​    return 0;
​​​​}
​​​
​​​​
​​​​
​​​​if(up(x,y,ptr,col)=='X'){
​​​​       
​​​​        if(right(x,y,ptr,col)!='X' && right(x,y,ptr,col)!='.'){
​​​​          
​​​​            path_exist(ptr,row,col,x+1,y);
​​​​        }
​​​​       else if(left(x,y,ptr,col)!='X' && left(x,y,ptr,col)!='.'){
​​​​            path_exist(ptr,row,col,x-1,y);
​​​​        }
​​​​       else if(down(x,y,ptr,col)!='X' && down(x,y,ptr,col)!='.'){
​​​​            path_exist(ptr,row,col,x,y+1);
​​​​        }
​​​​        
​​​​     
​​​​    }else if(up(x,y,ptr,col)!='.'){
​​​​         path_exist(ptr,row,col,x,y-1);}
​​​​    
​​​​  
​​​​
​​​​if(right(x,y,ptr,col)=='X' ){
​​​​    if(up(x,y,ptr,col)!='X' && up(x,y,ptr,col)!='.') {
​​​​        path_exist(ptr,row,col,x,y-1);
​​​​        
​​​​    }
​​​​    else if(left(x,y,ptr,col)!='X' && left(x,y,ptr,col)!='.'){
​​​​        path_exist(ptr,row,col,x-1,y);
​​​​        
​​​​    }
​​​​    else if(down(x,y,ptr,col)!='X' && down(x,y,ptr,col)!='.'){
​​​​        path_exist(ptr,row,col,x,y+1);

​​​​    } 
​​​​     
​​​​}else if(right(x,y,ptr,col)!='.'){
​​​​     path_exist(ptr,row,col,x+1,y);}
​​​​
​​​​if(down(x,y,ptr,col)=='X' ){
​​​​    
​​​​       if(up(x,y,ptr,col)!='X' && up(x,y,ptr,col)!='.') {
​​​​           path_exist(ptr,row,col,x,y-1);
​​​​        
​​​​       }
​​​​       else if(left(x,y,ptr,col)!='X' && left(x,y,ptr,col)!='.'){
​​​​           path_exist(ptr,row,col,x-1,y);
​​​​           
​​​​       }
​​​​       else if(right(x,y,ptr,col)!='X' && right(x,y,ptr,col)!='.'){
​​​​           path_exist(ptr,row,col,x+1,y);
​​​​            
​​​​       }
​​​​     
​​​​}else if(down(x,y,ptr,col)!='.'){
​​​​     path_exist(ptr,row,col,x,y+1);}
​​​​    
​​​​    if(left(x,y,ptr,col)=='X' ){
​​​​    
​​​​        
​​​​         if(up(x,y,ptr,col)!='X' && up(x,y,ptr,col)!='.') {
​​​​             path_exist(ptr,row,col,x,y-1);
​​​​             
​​​​        }
​​​​         else if(down(x,y,ptr,col)!='X' && down(x,y,ptr,col)!='.'){
​​​​             path_exist(ptr,row,col,x,y+1);
​​​​            
​​​​        }
​​​​         else if(right(x,y,ptr,col)!='X' && right(x,y,ptr,col)!='.'){
​​​​             path_exist(ptr,row,col,x+1,y);
​​​​            
​​​​        } 
​​​​     
​​​​    
​​​​  
​​​​}else if(left(x,y,ptr,col)!='.'){
​​​​     path_exist(ptr,row,col,x-1,y);}

}

int path_star(char* ptr,int row,int col,int x,int y){

​​​​if ((x*y)==(row*col)){
​​​​    if (*(ptr+(col*y)+x)=='.'){
​​​​    *(ptr+(col*y)+x)='*';}
​​​​    return 0;
​​​​}
​​​​if (x==col){
​​​​    if (*(ptr+(col*y)+x)=='.'){
​​​​         
​​​​    *(ptr+(col*y)+x)='*';}
​​​​    return path_star(ptr,row,col,0,y+1);
​​​​}
​​​​else if (*(ptr+(col*y)+x)=='.'){
​​​​    *(ptr+(col*y)+x)='*';
​​​​    return path_star(ptr,row,col,x+1,y);
​​​​}else{

​​​​    return path_star(ptr,row,col,x+1,y);
​​​​}

}

int main() {
int x,y,length,l;

​​​​char *char_arr,*temp;
​​​​int count=1;
​​​
​​​
​​​​char_arr=(char *) malloc(101*sizeof(char));
​​​​scanf("%d %d",&x,&y);
​​​​getchar();
​​​​fgets(char_arr,101,stdin);
​​​​length=strlen(char_arr);
​​​​l=length;
​​​​if (length<=100){
​​​​    
​​​​    temp=(char*) realloc(char_arr,(length+1)*2);
​​​​    if (temp!=NULL){
​​​​        char_arr=temp;
​​​​       
​​​​     
​​​​    }
​​​​}

while (fgets(char_arr+length,l+1,stdin)!=NULL){
length+=strlen(char_arr+length);
temp=(char*) realloc(char_arr ,((length+1)*(count+2))*sizeof(char));
char_arr=temp;
count++;

}
path_exist(char_arr,count,l,x,y);

if (global_res==1){
path_star(char_arr,count,l,0,0);
}

printing(char_arr,count,l);

free(char_arr);

​​​​/* TODO: Implement here */
​​​​
​​​​
​​​​return 0;

}