Advertisement
N-am

Untitled

Sep 27th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5. #include <sstream>
  6. #include <fstream>
  7.  
  8. using namespace std;
  9.  
  10.  
  11. int main()
  12. {
  13. system("COLOR FC");
  14. cout <<"\n=====================================================\n";
  15. cout <<"\nVersion 1.0\n";
  16. cout <<"\nSelecteaza Optiunea\n";
  17. cout <<"1. Inchide PC dupa Timer \n";
  18. cout <<"2. Restart \n";
  19. cout <<"3. Anuleaza Oprirea \n";
  20. cout <<"4. Scrie in fisier \n";
  21. cout <<"5. Read \n";
  22. cout <<"\n=====================================================\n";
  23. getch();
  24.  
  25. bool run = true;
  26. while (run)
  27. {
  28.  
  29. int liOption;
  30.  
  31. cin>>liOption;
  32.  
  33. switch( liOption )
  34. {
  35. case 1:
  36. {
  37. int liMinute;
  38. cout << "[ SHUTDOWN ] Introdu minutele: ";
  39. cin>>liMinute;
  40.  
  41. if ( liMinute <= 0 || liMinute >= 1000 )
  42. {
  43. cout << "[ EROARE ] Introdu o valoare de la 1-999 minute.\n" << endl;
  44. break;
  45. }
  46.  
  47. int secunde = liMinute * 60;
  48. cout << "[ SHUTDOWN ] In " << liMinute << " minute ( " << secunde << " secunde ) se inchide calculatorul.\n";
  49. stringstream ss;
  50. ss << "shutdown -s -t " << liMinute * 60;
  51. system( ss.str().c_str() );
  52. break;
  53. }
  54. case 2:
  55. {
  56. system("restart.exe");
  57. cout << "[ RESTART ] Restartarea incepe..\n" ;
  58. break;
  59. }
  60. case 3:
  61. {
  62. system("shutdown.exe -a");
  63. cout << "[ SHUTDOWN ] Oprirea a fost anulata.\n" ;
  64. break;
  65. }
  66. case 4:
  67. {
  68. string text;
  69. cout << "Introdu textu: " ;
  70. cin>>text;
  71.  
  72. ofstream myfile ( "Notes.txt", ios_base::app);
  73. myfile << text << "\n";
  74. myfile.close();
  75. break;
  76. }
  77. case 5:
  78. {
  79. cout <<"\n====================== [ Notes ] ======================\n";
  80. string Rows;
  81. ifstream MyFile ( "Notes.txt" );
  82. if ( MyFile.is_open() )
  83. {
  84. while ( getline( MyFile, Rows ) )
  85. {
  86. cout << Rows << '\n';
  87. }
  88. MyFile.close();
  89. }
  90.  
  91. else cout << "Fisierul cu notite este gol.";
  92. cout <<"\n========================================================\n";
  93. }
  94. }
  95. }
  96. return 0;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement