C++ 编程 关机小助手
原创
©著作权归作者所有:来自51CTO博客作者R9527的原创作品,请联系作者获取转载授权,否则将追究法律责任
#include<iostream>
using namespace std;
int main()
{ for(int i=0;;i++)
{
system("cls");
char ch;
void restar();//重启函数声明
void logout();//注销函数声明
void close();//关机函数声明
void offtime();//定时关机函数声明
void exit();
cout<<"\n\n\n";
cout<<" 阿 的 多 小 助 手 "<<endl<<endl<<endl;
cout<<" ************** 1.重启 **************"<<endl<<endl;
cout<<" ************** 2.注销 **************"<<endl<<endl;
cout<<" ************** 3.关机 **************"<<endl<<endl;
cout<<" ************** 4.定时关机 **********"<<endl<<endl;
cout<<" ************** 5.退出 **************"<<endl<<endl;
cout<<" *** 作者:偶遇 qq:1398195383 ***"<<endl<<endl;
cout<<" 请选择:";
ch=getchar();
switch(ch)
{
case '1':restar();break;
case '2':logout();break;
case '3':close();break;
case '4':offtime();break;
case '5':exit();break;
}
}
}
void restar()//重启函数
{
cout<<endl<<endl;
cout<<" 你确定要重启吗?{是(Y或者y)否(N或者n)}:";
char ch1;
cin>>ch1;
if(ch1=='y'||ch1=='Y')
{
cout<<"\n\n 正在重启......."<<endl<<endl;
system( "shutdown -r -t 0" );
}
else if(ch1=='n'||ch1=='N')
{
cout<<"\n\n 慎重考虑后,不重启!\n"<<endl<<endl;
}
}
void logout()//注销函数
{
cout<<endl<<endl;
cout<<" 你确定要注销吗?{是(Y或者y)否(N或者n)}:";
char ch2;
cin>>ch2;
if(ch2=='y'||ch2=='Y')
{
cout<<"\n\n 正在注销......."<<endl<<endl;
system( "shutdown -l" );
}
else if(ch2=='n'||ch2=='N')
{
cout<<"\n\n 慎重考虑后,不注销!\n"<<endl<<endl;
}
}
void close()//关机函数
{
cout<<endl<<endl;
cout<<" 你确定要关机吗?{是(Y或者y)否(N或者n)}:";
char ch3;
cin>>ch3;
if(ch3=='y'||ch3=='Y')
{
cout<<"\n\n 正在关机中......."<<endl<<endl;
system( "shutdown -p" );
}
else if(ch3=='n'||ch3=='N')
{
cout<<"\n\n 慎重考虑后,不关机!\n"<<endl<<endl;
}
}
void offtime()//定时关机函数
{
char ch4;
cout<<"\n\t 请选择要关机的时间!"<<endl;
cout<<"\n\t 1.10分钟 \n\t";
cout<<"\n\t 2.30分钟 \n\t";
cout<<"\n\t 3.60分钟 \n\t";
cout<<"\n\t 4.120分钟 \n\t";
cout<<"\n\t 5.150分钟 \n\t";
cout<<"\n\t 6.退出 \n\t";
cout<<"\n\t 请选择:";
cin>>ch4;
switch(ch4)
{
case '1':cout<<"\n\t 你的机子将在10分钟后关闭!";
system("shutdown -s -t 600");break;
case '2':cout<<"\n\t 你的机子将在30分钟后关闭!";
system("shutdown -s -t 1800");break;
case '3':cout<<"\n\t 你的机子将在1小时后关闭!";
system("shutdown -s -t 3600");break;
case '4':cout<<"\n\t 你的机子将在2小时后关闭!";
system("shutdown -s -t 7200");break;
case '5':cout<<"\n\t 你的机子将在2个半后后关闭!";
system("shutdown -s -t 9000");break;
case '6':exit(6);break;
}
}
void exit()
{
cout<<endl<<endl;
cout<<" 你确定要退出吗?{是(Y或者y)否(N或者n)}:";
char ch5;
cin>>ch5;
if(ch5=='y'||ch5=='Y')
{
cout<<"\n\n 已退出......."<<endl<<endl;
}
else if(ch5=='n'||ch5=='N')
{
cout<<"\n\n 慎重考虑后,不退出!\n"<<endl<<endl;
}
}
上一篇:C++ 编程 图的最短算法
下一篇:我的友情链接

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
C++关机程序
源代码:#include#includeint main() { HANDLE hToken; TO 0
Windows #include Server -
C/C++控制Windows关机/注销/重启的正确姿势
简介 说到代码控制Windows关机/注销...
#include 重启 命令行 -
关机程序(C)
关机程序(C)
关机程序 -
【C++】C++入门
学习完C语言后就要迈入C++的新征程了,本文介绍了C++入门时相较于C语言而增加的新概念的讲解与使用。
命名空间 编译器 缺省参数 引用 auto -
【C/C++】C/C++博客汇总C C++ C语言 C知识 C++汇总
-
C++ | C++模板
C++ | C++模板模板是泛型编程的基础,泛型编程即以一种独立于任何特定类型的方式编写代码。模板是创建泛型
c++ Stack #include 数据类型