Advertisement
Guest User

stoper c++

a guest
Jan 22nd, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <fstream>
  4. #include <cstdlib>
  5. #include <stdio.h>
  6.  
  7. using namespace std;
  8.  
  9. clock_t start,stop;
  10. float wersja=1.5;
  11. int wybor;
  12. float wyniki[100];
  13. int wynik;
  14.  
  15.  
  16. string linia;
  17. int nr_linii=1;
  18.  
  19. fstream czasy;
  20.  
  21.  
  22.  
  23. fstream czasyin;
  24.  
  25. void stoper()
  26. {
  27.     int czas;
  28.     cout << endl <<"Aby wlaczyc stoper wcisnij jakikolwiek klawisz " << endl;
  29.     getchar();
  30.     getchar();
  31.     start = clock();
  32.     cout << endl <<"Odliczanie trwa, wcisnij jakikolwiek klawisz aby zatrzymac odliczanie";
  33.     getchar();
  34.     stop = clock();
  35.     czas = (stop-start) / CLOCKS_PER_SEC;
  36.     czasyin.open("Czasy.txt", ios::out | ios::app);
  37.     czasyin<<czas<<endl;
  38.     czasyin.close();
  39.     cout << endl << "Czas to:"<< czas << " sec" << endl;
  40.     cout << endl << "*Nacisniecie klawisza spowoduje wyjscie do menu" << endl;
  41.     getchar();
  42. }
  43.  
  44.  
  45. int main()
  46. {
  47.  
  48.  
  49.     for(;;)
  50.     {
  51.         cout << "Stoper MostTime "<<wersja<<" Console" << endl;
  52.         cout << "**********MENU************" << endl;
  53.         cout << "1. Stoper"<< endl;
  54.         cout << "2. O programie"<< endl;
  55.         cout << "3. Pokaz czasy"<< endl;
  56.         cout << "4. Dodaj czas"<< endl;
  57.         cout << "0. EXIT"<< endl;
  58.         cout <<"**********MENU************" << endl;
  59.         cout << "Wybierz:";
  60.         int licznik=0;
  61.         cin >> wybor;
  62.  
  63.         switch (wybor)
  64.         {
  65.         case 1:
  66.             stoper();
  67.  
  68.             break;
  69.         case 2:
  70.             cout << "Wersja "<<wersja<<" WORK-IN-PROGRESS" << endl;
  71.             cout << endl << "*Nacisniecie klawisza spowoduje wyjscie do menu" << endl;
  72.             getchar();
  73.             getchar();
  74.             break;
  75.         case 3:
  76.             czasy.open("Czasy.txt", ios::in);
  77.             while(!czasy.eof())
  78.             {
  79.                 getline(czasy, linia);
  80.                 wyniki[licznik]=atof(linia.c_str());
  81.                 licznik++;
  82.             }
  83.             czasy.close();
  84.             for (int i=0; i<(licznik-1); i++)
  85.             {
  86.  
  87.                 cout<<wyniki[i]<<endl;
  88.  
  89.             }
  90.  
  91.             cout<<"Koniec czasow"<<endl;
  92.  
  93.             getchar();
  94.             getchar();
  95.             break;
  96.         case 4:
  97.             cout << "Wpisz czas do pliku"<<endl;
  98.             cin>>wynik;
  99.             czasyin.open("Czasy.txt", ios::out | ios::app);
  100.             czasyin<<wynik<<endl;
  101.             czasyin.close();
  102.             break;
  103.         case 0:
  104.             exit(0);
  105.             break;
  106.         default:
  107.             cout << "Nie ma takiej opcji"<<endl;
  108.             cout << endl << "*Nacisniecie klawisza spowoduje wyjscie do menu" << endl;
  109.             getchar();
  110.             getchar();
  111.         }
  112.         system("cls");
  113.     }
  114.     return 0;
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement