Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.47 KB | None | 0 0
  1. #include "write.h"
  2.  
  3. void TimeFile(int menor, int maior, int casos, string bin, chrono::duration<double, milli> **tempo, ofstream& ofs_, string filename, int **passos) {
  4.     /*Output file containing information over array size and time spent on search.*/
  5.     size_t dot = filename.find('.');
  6.     string t[] = {"ILS", "IBS", "RBS", "ITS", "RTS", "FBS", "JS"};
  7.     string temp;                                //String where i will store my temporaly filenames.
  8.  
  9.     for(int i=0; i<=casos; i++) {
  10.         /*Now, I also print some of the information adquired on the terminal.*/
  11.         cout << "Algorithm    " << "#Size      " << "Time       " << "Iterations" << endl;
  12.         cout << setw(50) << setfill('-') << ": ";
  13.         cout << endl;
  14.         for(int j=0; j<7; j++) {
  15.             if(bin[j] == '1') {
  16.                 temp.assign(filename);                  //Restarting string 'temp' as original parameter 'filename'.
  17.                 temp.insert(dot, "_");                  //Putting a '_' right before the dot in string 'filename'.(temp).
  18.                 temp.insert(dot+1, t[j]);               //Putting Algorithm name, to differ one file from another.
  19.  
  20.                 ofs_.open(temp.c_str(), ofstream::app);        //Opens output stream.
  21.                 ofs_ << menor+i*(maior-menor)/casos << " ";         //Printing on file the size of analised array.
  22.                 ofs_ << tempo[i][j].count() << endl;                //Printing on file the time spent com it's correspondent array size.
  23.  
  24.                 /*Here, I print on the terminal as well.*/
  25.                 if(j==6) {
  26.                     cout << t[j] << ":        " << menor+i*(maior-menor)/casos << "      " << tempo[i][j].count() << "ms     " << passos[i][j] << " iterations." << endl;
  27.                     continue;
  28.                 }
  29.                 cout << t[j] << ":       " << menor+i*(maior-menor)/casos << "      " << tempo[i][j].count() << "ms       " << passos[i][j] << " iterations." << endl;
  30.                 ofs_.close();
  31.             }
  32.         }
  33.         cout << endl;
  34.     }
  35. }
  36.  
  37. void StepFile(int menor, int maior, int casos, string bin, int **passos, ofstream& ofs_, string filename) {
  38.     /*Outout file containing information over array size in association with steps took by the main function on determined search algorithm.*/
  39.     size_t dot = filename.find('.');
  40.     string t[] = {"ILS", "IBS", "RBS", "ITS", "RTS", "FBS", "JS"};
  41.     string temp;                                //String where i will store my temporaly filenames.
  42.  
  43.     for(int j=0; j<7; j++) {
  44.         if(bin[j] == '1') {
  45.             temp.assign(filename);                  //Restarting string 'temp' as original parameter 'filename'.
  46.             temp.insert(dot, "_");                  //Putting a '_' right before the dot in string 'filename'.(temp).
  47.             temp.insert(dot+1, t[j]);               //Putting Algorithm name, to differ one file from another.
  48.             ofs_.open(temp.c_str(), ofstream::app);             //Opens output stream.
  49.             for(int i=0; i<=casos; i++) {
  50.                 ofs_ << menor+i*(maior-menor)/casos << " ";         //Printing on file the size of analised array.
  51.                 ofs_ << passos[i][j] << endl;                //Printing on file the time spent com it's correspondent array size.
  52.             }
  53.             ofs_.close();
  54.         }
  55.     }
  56. }
  57.  
  58. //void Steps_out(int menor, int num_test, string bin, ofstream& ofs_, string filename) {
  59.     /* Output file containing number of iterations per */
  60. //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement