Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.00 KB | None | 0 0
  1. case 2:
  2.         begin = clock();
  3.         plik.open("rand.txt");
  4.         int g = 1;
  5.         for (int i = 0; i < numberOfNodes; i++)
  6.         {
  7.            
  8.             if ((numberOfInserted % 2) == 1)
  9.             {
  10.                 plik >> tab[i];
  11.                 insert(tab[i]);
  12.             }
  13.             else
  14.             {
  15.                 insert(g);
  16.                 g++;
  17.             }
  18.                
  19.         }
  20.         plik.close();
  21.         end = clock();
  22.         time_spent = (double)(end - begin) * CLOCKS_PER_SEC / 1000;
  23.         printf("Wstawiono %d elementow", numberOfInserted);
  24.         printf("\n%f ", time_spent);
  25.         ///////////////////////////////////////////////////////////////
  26.         begin = clock();
  27.         plik.open("rand.txt");
  28.         for (int j = 0; j < numberOfNodes; j++)
  29.         {
  30.             plik >> tab[j];
  31.             findKey(tab[j]);
  32.         }
  33.         plik.close();
  34.         end = clock();
  35.         time_spent = (double)(end - begin) * CLOCKS_PER_SEC / 1000;
  36.         printf("\nOdszukano %d elementow", numberOfInserted);
  37.         printf("\n%f ", time_spent);
  38.         ///////////////////////////////////////////////////////////////
  39.         begin = clock();
  40.         numberOfFound = 0;
  41.         for (int j = 0; j < numberOfNodes; j++)
  42.         {
  43.             int val = (rand() << 9) % 10000000;
  44.             findKey(val);
  45.         }
  46.         end = clock();
  47.         time_spent = (double)(end - begin) / CLOCKS_PER_SEC / 1000;
  48.         printf("\nOdszukano %d elementow", numberOfFound);
  49.         printf("\n%f ", time_spent);
  50.         //////////////////////////////////////////////////////////////////////
  51.         begin = clock();
  52.         for (int k = 0; k < numberOfNodes; k++)
  53.         {
  54.             int key = (rand() << 9) % 10000000;
  55.             remove(key);
  56.         }
  57.         end = clock();
  58.         time_spent = (double)(end - begin) * CLOCKS_PER_SEC / 1000;
  59.         printf("\n Usunieto %d elementow", numberOfRemoved);
  60.         printf("\n%f ", time_spent);
  61.         //////////////////////////////////////////////////////////////////////
  62.         begin = clock();
  63.         plik.open("rand.txt");
  64.         numberOfRemoved = 0;
  65.         for (int l = 0; l < numberOfNodes / 2; l++)
  66.         {
  67.             plik >> tab[l];
  68.             remove(tab[l]);
  69.         }
  70.         plik.close();
  71.         end = clock();
  72.         time_spent = (double)(end - begin) * CLOCKS_PER_SEC / 1000;
  73.         printf("\n Usunieto %d elementow", numberOfRemoved);
  74.         printf("\n%f ", time_spent);
  75.         break;
  76.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement