diff --git a/hangman.c b/hangman.c new file mode 100644 index 0000000..566ec86 --- /dev/null +++ b/hangman.c @@ -0,0 +1,256 @@ +/* Jared Wasserman -- hangman.c */ + +#include +#include +#include +#include +#include + +int memberq(char guessedLetters[],int size,char character){ + int guessed=0; + int x; + for(x=0;x0){ + return 1; + }else{ + return 0; + } +} + +int print(char word[],char guessedLetters[26],int numOfGuess,int incorrectGuesses){ + int i; + printf("\n"); + for(i=0;i +#include +#include + +int main(){ + srand(time(NULL)); + int m; + int n; + float p; + + /*Getting And Checking Input*/ + int returnValue; + do{ + printf("Enter m dimension: "); + returnValue = scanf("%d",&m); + if(returnValue==0){ + printf("Invalid Input. "); + while(getchar()!='\n'); + } + }while(returnValue==0); + while(getchar()!='\n'); + do{ + printf("Enter n dimension: "); + returnValue = scanf("%d",&n); + if(returnValue==0){ + printf("Invalid Input. "); + while(getchar()!='\n'); + } + }while(returnValue==0); + while(getchar()!='\n'); + do{ + printf("Enter probalility (between 0 & 1): "); + returnValue = scanf("%f",&p); + if(returnValue==0||p<=0||p>=1){ + printf("Invalid Input. "); + while(getchar()!='\n'); + } + }while(returnValue==0||p<=0||p>=1); + + int p2=(100*p); + int arr[m][n]; + int x; + int y; + + /*Placing The Mines*/ + for(x=0;x(m-1)||sur[a][1]<0||sur[a][1]>(n-1)){ + /*Out of bounds*/ + }else{ + if(arr[sur[a][0]][sur[a][1]]==-1){ + count++; + } + } + } + arr[x][y]=count; + } + } + } + + /*Printing The Board*/ + for(x=0;x