Simon says

Hello good night, I'm new to C++ and I'm having some problems. My program is to present the user one more letter per round correct, each move is added a character more. But what I need to do is to show up one by one, with a time interval ... I've tried several cycles, but it never works for me. Help, please ....

// simon.cpp: define el punto de entrada de la aplicaciĆ³n de consola.
//

#include "stdafx.h"
#include <conio.h>
#include <iostream>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <Windows.h>

using namespace std;
int main()
{
// variable declaration, initialization
string seq[5];
seq[0] = " ", seq[1] = " ", seq[2] = " ", seq[3] = " ", seq[4] = " ";
string userseq[5];
userseq[0] = " ", userseq[1] = " ", userseq[2] = " ", userseq[3] = " ", userseq[4] = " ";
char color[4];
color[0] = 'R';
color[1] = 'G';
color[2] = 'B';
color[3] = 'Y';
int round;
int n = 0;
round = 1;
srand(time(NULL));


while (round < 5)
{
int i = 0; int c = 0;
// Displays and erases sequence
//seq[i] += color[rand() % 4];
srand(time(NULL));
n = 0 + rand() % (3 + 1 - 0);
seq[i] = color[n];
cout << "para comenzar presione enter...";
_getch();
system("cls");
_getch();
/*do
{*/
for (int i = 0;i < round;i++)
{
cout << seq[i] << flush;
Sleep(200);
//cout << seq[i] << flush;
system("cls");
//cout << seq[i+1] << flush;
//c++;
//} while (c < 5);
//cout << "\010." << flush << '\n';
}



cout << "\nIngrese " << round << " caracteres mostrados:";
cin >> userseq[i];





if (userseq[i] != seq[i])
{
cout << "Perdiste! La secuencia correcta fue: " << seq[i];
break;
}



if (round == 5)
{
cout << "Ganaste!";
break;
}
round++;
i++;
}

_getch();
return 0;
}
Topic archived. No new replies allowed.