Но рандомом выбираются всё время одинаковые карты. Что не так здесь? Буду благодарен, если посмотрите!
#include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>
#include <cmath>
using namespace std;
typedef string str5;
typedef enum {PIKI,TREF,BUBN,CHER} MAST;
typedef enum {K6,K7,K8,K9,K10,KVAL,KDAM,KKOR,KTUZ} ZNACH;
const str5 Mast_STR[]={"Pik","Tref","Buben","Chervey"};
const str5 Znach_STR[]={"6","7","8","9","10","Valet","Dama","Korol`","TUZ"};
struct KARTA {
public:
MAST M;
ZNACH Z;
};
int _tmain(int argc, _TCHAR* argv[]){
KARTA K1,K2,KTemp,Koloda[36];
MAST KM;
ofstream fout;
for(int i=PIKI;i<=CHER;i++)
for(int j=K6;j<=KTUZ;j++){
Koloda[i*9+j+1].M=MAST(i);
Koloda[i*9+j+1].Z=ZNACH(j);
}
for(int i=0;i<1000;i++){
int n=rand()%36;
int m=rand()%36;
if (n!=m){
KTemp=Koloda[n];
Koloda[n]=Koloda[m];
Koloda[m]=KTemp;
}
}
K1=Koloda[1];
K2=Koloda[2];
cout<<"Pervaya karta: "<<Znach_STR[K1.Z]<<" - "<<Mast_STR[K1.M]<<endl;
cout<<"Vtoraya karta: "<<Znach_STR[K2.Z]<<" - "<<Mast_STR[K2.M]<<endl;
fout<<"Pervaya karta: "<<Znach_STR[K1.Z]<<" - "<<Mast_STR[K1.M]<<endl;
fout<<"Vtoraya karta: "<<Znach_STR[K2.Z]<<" - "<<Mast_STR[K2.M]<<endl;
KM=MAST(rand()%4);
cout<<"Kozir`: "<<Mast_STR[KM]<<endl;
fout<<"Kozir`: "<<Mast_STR[KM]<<endl;
if (((K1.M=K2.M)&&(K1.Z>K2.Z)) || ((K1.M=KM)&&(K2.M!=KM))){
cout<<"Karta 1 byet kartu 2!";
fout<<"Karta 1 byet kartu 2!";
}
else {
cout<<"Karta 1 NE byet kartu 2!";
fout<<"Karta 1 NE byet kartu 2!";
}
fout.close();
cin.get();
return 0;
}




