Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // by steef
- #include <iostream>
- #include <cstdlib>
- #include <string>
- using namespace std;
- int main()
- {
- string time;
- int val;
- cout << "voulez-vous effectuer un arret(1) ou annuler un arret planifie(2) ?" << endl;
- cout << "Entrez un chiffre : " << endl;
- cin >> val;
- if (val == 1) {
- cout << "Entrez l'heure d'arret de la machine (format-> XXhXX)" << endl;
- getline(cin, time);
- getline(cin, time);
- if (time.size() != 5) cout << "erreur de saisie" << endl;
- else
- {
- int heure = stoi(time.substr(0, 2));
- int minutes = stoi(time.substr(3, 4));
- int seconde;
- cout << "Ton ordinateur s'eteindra dans " << heure << " heure(s) et " << minutes << " minute(s)" << endl;
- seconde = (minutes * 60) + (heure * 3600);
- cout << "Soit dans " << seconde << " seconde(s)" << endl;
- string command = "C:/Windows/System32/shutdown.exe -s -t " + to_string(seconde);
- cout << command << endl;
- system(command.c_str());
- }
- }
- else if (val == 2)
- system("C:/Windows/System32/shutdown.exe -a");
- else cout << "erreur de saisie" << endl;
- getline(cin, time);
- getline(cin, time);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment