关机(可以计时)(新增倒计时)(新增死神版)
作者:
sy2020lyk
,
2021-10-23 20:19:08
,
所有人可见
,
阅读 331
今天lyk给大家介绍一个关机程序
思路
system("shutdown -s -t 0");关机
clock()计时
c++代码
#include<bits/stdc++.h>
#include<ctime>
#include<windows.h>
using namespace std;
int t;
int main(){
cout<<"你想几秒后关机?";
cin>>t;
int k=clock();
int kk=clock();
k+=t;
while(kk<k){
kk=clock();
}
system("shutdown -s -t 0");
}
以下是倒计时版
#include<bits/stdc++.h>
#include<ctime>
#include<windows.h>
using namespace std;
int t;
int main(){
cout<<"你想几秒后关机?";
cin>>t;
int k=clock();
int kk=clock();
k+=t;
while(kk<k){
system("cls");
kk=clock();
cout<<k-kk;
}
system("shutdown -s -t 0");
}
再来一个死神(不定期)版
思路 用rand()确定时间
死神版 1
#include<bits/stdc++.h>
#include<ctime>
#include<windows.h>
#include<cstdlib>
using namespace std;
int t;
int main(){
srand((unsigned)time(0));
t=rand()%10;
int k=clock();
int kk=clock();
k+=t;
while(kk<k){
system("cls");
kk=clock();
cout<<k-kk;
}
system("shutdown -s -t 0");
}
死神版2
#include<bits/stdc++.h>
#include<ctime>
#include<windows.h>
#include<cstdlib>
using namespace std;
int t;
int main(){
srand((unsigned)time(0));
int k=clock();
int kk=clock();
k+=t;
while(t==5){
t=rand()%10;
}
system("shutdown -s -t 0");
}
啊啊啊好恐怖啊(………………………………………………)
死神版其实是你不知道什么时候关机,像你不知道什么时候死一样
hhh
我当然知道
但是……这是在关机键无法使用的时候执行的吧……