Skip to content
Extraits de code Groupes Projets
Valider f79f8518 rédigé par Hugo TRACHINO's avatar Hugo TRACHINO
Parcourir les fichiers

PM finally

parent 550fe72e
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
using namespace std;
const unsigned int n = 0xFFFF;
const unsigned int m = 16807;
const unsigned int b = 0;
static long seed = 0xAAAA;
long uniform() {
long unsigned int hi = m * (seed & n);
long unsigned int lo = m * (seed >> 16);
lo+= (hi & 0x7FFF) << 16;
lo+= hi >> 15;
if (lo > 0x7FFFFFFFF)
lo -= 0x7FFFFFFF;
seed=(long) lo;
return seed %10;
}
void store_res(long * res, int freqs[10], int size){
std::ofstream myfile, freqcsv;
myfile.open("gva_res.csv");
freqcsv.open("gva_freqs.csv");
int i;
for (i = 0; i < size; i ++){
freqs[res[i]] ++;
myfile << res[i];
myfile << "\n";
}
for (i=0; i < 10; i++){
freqcsv << "0.";
freqcsv << i;
freqcsv << ", ";
freqcsv << freqs[i];
freqcsv << "\n";
}
myfile.close();
freqcsv.close();
}
int main(int argc, char **argv) {
if(argc <2)
return -1;
long unif[atoi(argv[1])];
// create the outputs
for (int i = 0; i < atoi(argv[1]); i++)
unif[i] = uniform();
// store hist freqs
int freqs[10];
for(int i=0; i < 10; i ++)
freqs[i] = 0;
store_res(unif, freqs, atoi(argv[1]));
for (int i = 0; i < atoi(argv[1]); i++)
cout << unif[i] << endl;
}
Fichier ajouté
Fichier ajouté
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter