當前位置:編程學習大全網 - 源碼下載 - 求《c++編寫的定時關機程序源代碼

求《c++編寫的定時關機程序源代碼

那時才學了2個月的C語言代碼如下:

#include<stdio.h>

main()

{

char ch='\0';

while(ch=2)

{

system("cls");

printf("\n\t**************************\n\t");

printf("\n\t 請選擇妳要執行的命令: \n\t");

printf("\n\t*** 1.重啟 ***\n\t");

printf("\n\t*** 2.關機 ***\n\t");

printf("\n\t*** 3.註銷 ***\n\t");

printf("\n\t*** 0.退出 ***\n\t");

printf("\n\t**************************\n\t");

ch=getchar();

switch(ch)

{

case '1':{printf("確認要重啟?(Y/N)");

ch=getch();

if(ch=='Y'||ch=='y')

system("shutdown -r ");

break;

}

case'2':{printf("確認要關機?(Y/N)");

ch=getch();

if(ch=='Y'||ch=='y')

{ printf("請選擇妳要執行的命令:");

printf("\n\t*** 1.快速關機 ***\n\t");

printf("\n\t*** 2.定時關機 ***\n\t");

printf("\n\t*** 0.退出 ***\n\t");

ch=getch();

switch(ch)

{

case '1':system("shutdown -s");break;

case '2':{ printf("請選擇要關機的時間:");

printf("\n\t 1.30分鐘 \n\t");

printf("\n\t 2.60分鐘 \n\t");

printf("\n\t 3.90分鐘 \n\t");

printf("\n\t 4.120分鐘 \n\t");

printf("\n\t 5.150分鐘 \n\t");

ch=getch();

switch(ch)

{

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':system("shutdown -s -t 9000");break;

default:printf("輸入錯誤!");break;

}

}

case '0':exit(0);break;

default:printf("輸入錯誤!");break;

}

}

else break;

}

case '3':{printf("確認要註銷?(Y/N)");

ch=getch();

if(ch=='Y'||ch=='y')

system("shutdown -l ");

break;

}

case '0':exit(0);break;

default:printf("輸入錯誤!");

}

}

}

看看裏面的關機語句,自己領悟吧。當時是壹個新手,註釋都不沒寫,這是壹個不好的習慣,妳學C語言的話,壹定要記得寫哦!這是方便自己檢查錯誤還有方便別人查看。

  • 上一篇:要智能更要好音質 斐訊AI音箱R1使用體驗
  • 下一篇:在java中,遍歷hashmap用什麽方法
  • copyright 2024編程學習大全網