1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#include <iostream> // std::cout
#include <algorithm> // std::move_backward
#include <array> // std::array
#include <random> // std::default_random_engine
#include <chrono> // std::chrono::system_clock
#include <fstream> //ein ausgabe in txt datei
int i, j, k;
int Array[6][1];
int main() {
std::array<int, 10> NrArray{ 403, 301, 104, 315, 123, 172, 208, 309, 410, 121 };
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
shuffle(NrArray.begin(), NrArray.end(), std::default_random_engine(seed)); //til here the programm shuffles the ArrayNR
for (i = 0; i <= 5; i++){
k = NrArray[i]; //here the programm starts to pick numbers from the array and fills the Array "Array" with it(next time i'll pick another name)^^
for (j = 4; j>0; j--){
if (k> j * 100){
Array[i][0] = k - j * 100;
Array[i][1] = j;
j = 1;
}
}
printf("Karte %d\n", Array[i][0]);
printf("%d\n", Array[i][1]); //the output is correct
}
//output txt
std::ofstream a_file("RandomHand.txt");
for (i = 0; i <= 5; i++){
a_file << "Hoehe " << Array[i][0] << " Tiefe " << Array[i][1] << std::endl;
printf("Karte %d\n", Array[i][0]);
printf("%d\n", Array[i][1]); //the output changed as mentioned in OP Array[i][0]=[Array[0][i]
}
a_file.close();
return 0;
}
|