Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- string word[] = { "award", "await", "attend", "bubble", "coding", "spring", "mango", "night", "orange", "reward"};
- string m,n;
- int x;
- char c;
- srand(time(0));
- m=word[rand()%10];
- n=m;
- x=m.length();
- char a[x];
- for(int i=0; i<x;i++){
- m[i]='-';
- }
- cout<<m<<endl;
- for(int i=0;i<x+2;i++){
- cout<<"Guess a letter: ";
- cin>>c;
- for(int j=0;j<x;j++){
- if(n[j]==c){
- m[j]=c;
- }
- }
- cout<<m<<endl;
- if(m==n){
- cout<<"Correct guess!"<<endl;
- break;
- }
- }
- if(m!=n){
- cout<<endl;
- cout<<"Guessed wrong"<<endl;
- cout<<endl;
- cout<<"Word was : "<<n<<endl;
- }
- return 0;
- }
- kk
Add Comment
Please, Sign In to add comment