#include <iostream>
#include <stdlib.h>
using namespace std;
void main()
{
int k=0;
int tab[]={1,2,3};
int x1=0;
int x2=0;
int x3=0;
randomize();
// 1 LOSOWANIE
k=rand()%3+1;
x1=tab[k];
// 2 LOSOWANIE
do
{
k=rand()%3+1;
x2=tab[k];
} while(k==x1);
// 3 LOSOWANIE
do
{
k=rand()%3 +1;
x3=tab[k];
} while(k==x1 && k==x2);
cout<<"x1 = "<<x1<<endl;
cout<<"x2 = "<<x2<<endl;
cout<<"x3 = "<<x3<<endl;
system("pause");
}
hej jest to tylko fragment kodu który piszę, ale jest to dla mnie ważne bo to jest kluczowe w pewnym sensie.
Pytanie, dlaczego pomimo tego, że nie pozwalam na wylosowanie tego samego indexu do zmienne nadal mogą mieć te same wartości?</cpp>