Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <fstream>
- #include <ctime>
- void generazione_dati (int &a, int &b) {
- std::fstream f;
- f.open ("conf.txt");
- a = rand()% 25 + 1;
- b = rand()% 25 + 1;
- f << a << b << ",";
- f.close();
- }
- void riempimento_dati (int a, int b, int** arr) {
- for (int i=0; i<a; ++i) {
- for (int j=0; i<b; ++j)
- arr [i][j] = rand()% 256;
- }
- }
- void caricamento_dati (int a, int b, int** arr) {
- std::fstream f;
- f.open ("data.csv");
- for (int i=0; i<a; ++i) {
- for (int j=0; j<b; ++j) {
- if (j = b-1)
- f << arr [i][j];
- else
- f << arr [i][j] << ",";
- }
- f << "\n";
- }
- f.close();
- }
- int main() {
- srand(time(NULL));
- int a, b;
- generazione_dati (a, b);
- int** arr = new int* [a];
- for (int i=0; i<a; ++i)
- arr [i] = new int [b];
- riempimento_dati (a, b, arr);
- caricamento_dati (a, b, arr);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement