diff --git a/README.md b/README.md index 9846ba8..25c7029 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,9 @@ Example Output:

1 1 1 1 0 0 0 1 1 1 1 1 1 1
1 1 1 1 1 0 1 1 1 1 1 1 1 1
-#How to submit your code - -*Fork the repository -*When your code is ready, submit a pull request to the submissions branch -*Add a txt file with your name, any collaborators and your algorithm +#How to submit your code - +
    +
  1. Fork the repository +
  2. When your code is ready, submit a pull request to the submissions branch +
  3. Add a txt file with your name, any collaborators and your algorithm
diff --git a/Rohan Sharma_14CSE_Jarvis b/Rohan Sharma_14CSE_Jarvis new file mode 100644 index 0000000..ac9aeb1 --- /dev/null +++ b/Rohan Sharma_14CSE_Jarvis @@ -0,0 +1,137 @@ +/* +Name: Rohan Sharma +Roll no.: 14BTCSERS046 +Stream: CSE +Compiler: GNU GCC +IDE: Code Blocks +OS: Windows 8.1 Pro +*/ + +#include +#include +#include //for 'exit()' + +using namespace std; + +/*--------------- +Global Variables +-----------------*/ +int a[1024][1024]; + +/*---------------------------- +Function Declaration +------------------------------*/ +/* +This functions recursively fills the surroundings of a[i][j] (i,j are passed to the function) +Note: Surroundings are top, bottom, left, right +*/ +void fill_recursively(int,int); + +int main() +{ + char c; + int i,j,row=0,col=0; + ifstream fin; //to create input stream + fin.open("input.txt",ios::in); //to connect 'input.txt' to input stream 'fin' + fin.seekg(0); //to bring file pointer to file beginning + if(!fin) //to prompt error message if input file is not present + { + cout<<"Please add the file 'input.txt' in the same directory!\n\n"; + system("pause"); + exit(0); + } + while(!fin.eof()) //to count number of rows & columns & store the matrix from file in the 2D array 'a' + { + fin.get(c); + if(isdigit(c)) + { + a[row][col++]=c-48; + } + if(c=='\n') + { + row++; + col=0; + } + } + row++; + col--; + fin.close(); //to disconnect 'input.txt' from 'fin' + /* + To start filling from boundary of the 2D array + Note: Outside filled places become '2' + */ + for(i=0;i