Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <fstream>
- #include <ctime>
- #include <vector>
- 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, std::vector<std::vector<int>> &v) {
- for (int i=0; i<a; ++i) {
- for (int j=0; i<b; ++j)
- v[i].push_back(rand()% 256);
- }
- }
- void caricamento_dati (int a, int b, std::vector<std::vector<int>> &v) {
- 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 << v [i][j];
- else
- f << v [i][j] << ",";
- }
- f << "\n";
- }
- f.close();
- }
- int main() {
- srand(time(NULL));
- int a, b;
- generazione_dati (a, b);
- std::vector<std::vector<int>> v;
- riempimento_dati (a, b, v);
- caricamento_dati (a, b, v);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement