定时关机c++源码

来源:互联网 发布:手机海报拼图软件 编辑:程序博客网 时间:2024/06/01 10:17
#include <cstdlib>#include <iostream>using namespace std;int main(){int i;cout<<"1、关机"<<endl<<"2、重启"<<endl<<"3、注销"<<endl<<"4、休眠"<<endl<<"5、取消"<<endl;cin>>i;switch(i){case 1:{int j;cout<<"1、关机"<<endl<<"2、定时关机"<<endl<<"3、取消定时关机"<<endl<<"4、取消"<<endl;cin>>j;switch(j){case 1:system("shutdown -s -t 0");break;case 2:{int t;cout<<"1、30分钟后关机"<<endl<<"2、60分钟后关机"<<endl<<"3、90分钟后关机"<<endl<<"4、120分钟后关机"<<endl<<"5、取消"<<endl;cin>>t;switch(t){case 1:system("shutdown -s -t 1800");break;case 2:system("shutdown -s -t 3600");break;case 3:system("shutdown -s -t 5400");break;case 4:system("shutdown -s -t 7200");break;case 5:return 0;default:return 0;}break;}case 3:system("shutdown -a");break;case 4:return 0;default:return 0;}break;}    case 2:system("shutdown -r");break;    case 3:system("shutdown -l");break;    case 4:system("shutdown -h");break;    case 5:return 0;default:return 0;}return 0;}