Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- int main(){
- int round = 0;
- int counter = 0;
- int extraCounter = 0;
- int lostCounter = 0;
- bool found;
- string tempSolution;
- string tempGuess;
- while (round != -1){
- cin >> round;
- if(round == -1){
- break;
- }
- cin >> tempSolution;
- cin >> tempGuess;
- vector <char> solution(tempSolution.begin(), tempSolution.end());
- vector <char> guess(tempGuess.begin(), tempGuess.end());
- for (int i = 0; (unsigned)i < guess.size(); i++){
- for (int k = 0; (unsigned)k < solution.size(); k++){
- if (guess[i] == solution[k]){
- counter++;
- found = true;
- for(int j = 0; (unsigned)j < solution.size() - k; j++){
- if(solution[k] == guess[k+j+i+1]){
- extraCounter++;
- }
- }
- }
- }
- cout << "extra counter: " << extraCounter << endl;
- if(!found){
- guess[i] =
- lostCounter++;
- }
- found = false;
- }
- cout << "Round " << round << endl;
- if(lostCounter >= 7){
- cout << "You lose." << endl;
- }else if(lostCounter < 7 and (unsigned)counter < solution.size() + extraCounter) {
- cout << "You chickened out." << endl;
- }else if((unsigned)counter >= solution.size() + extraCounter){
- cout << "You win." << endl;
- }
- counter = 0;
- lostCounter = 0;
- solution.clear();
- guess.clear();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement