system函数指令

· · 算法·理论

以下是system函数指令(加讲解)(指令大小写都行)

1.color函数

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("color 6");//将输出的字体颜色转换为数字6指定的颜色
    system("color 8");//将背景设为8指定的背景颜色
    cout <<"hello!";//输出6指定颜色的“hello!”
    return 0;
}

以下是各种数字分别指定的字体颜色: | 数字 | 0 | 1 | 2 | 3 |4|5|6|7| |---|---|---|---|---|---|---|---|---| | 颜色 |黑|蓝| 绿 |浅绿|红|紫|黄|白|

以下是各种数字指定的背景颜色:

数字 8 9 A B C D E F
颜色 灰 淡蓝 淡绿 淡浅绿 淡红 淡紫 淡黄 亮白

2.cls清屏函数:

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    cout <<"你好啊!"<< endl;//输出字符串"你好啊!"
    system("cls");//清空终端,刚刚输出的字符串就不见了
    return 0;
}

3.calc函数

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("calc");//打开计算器
    return 0;
}

4.explorer函数

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("explorer");//打开资源管理器
    return 0;
}

5.pause暂停函数

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("pause");
    /*
    他会暂停程序,并弹出:
'\\Mac\Home\Documents'
用作为当前目录的以上路径启动了 CMD.EXE。
UNC 路径不受支持。默认值设为 Windows 目录。
请按任意键继续. . .
    */
    return 0;
}

6.mspaint函数

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("mspaint");//打开画图软件
    return 0;
}

7.start函数(用法一)

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("start cmd");//打开管理员窗口
    system("exit");//可退出cmd.exe
    /*
    system写的东西就是在cmd里运行的
    有某些人可能会尝试写某些代码:
    while(true)
        system(start cmd);
    关掉终端即可正常
    */
    return 0;
}

start函数(用法二)

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    //1.打开网站
    system("start 网站地址");//打开该网站(要加https://)
    //例如:
    system("start https://www.acgo.cn/discuss/study/52230");
    //2.打开文件
    syetm("start 文件名");//打开该文件(不要加https://)
    //例如:
    system("start in.put");
    return 0;
}

8.time和date

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("time");//显示当前时间
    system("date");//显示当前日期
    return 0;
}

9.notepad函数

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("notepad");//打开记事本
    return 0;
}

10.shutdown函数

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("shutdown -s -t 60")//60秒后关机,可将60改成其他以秒为单位的时间
    system("shutdown -a");//可以取消关机
    return 0;
}

11.cleanmgr函数

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("cleanmgr")//垃圾整理
    return 0;
}

12.mmc函数

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("mmc");//打开控制台
    return 0;
}

13.osk函数

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("osk");//打开屏幕键盘
    return 0;
}

14.taskmgr函数

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("taskmgr");//打开任务管理器
    return 0;
}
  1. eudcedit函数
    
    #include <bits/stdc++.h>
    #include <windows.h>
    using namespace std;

int main(){ system("eudcedit");//打开造字程序 return 0; }


16.eventvwr函数
```cpp
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("eventvwr");//打开事件查看器
    return 0;
}

17.compmgmt函数

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("compmgmt");//打开计算机管理
    return 0;
}

18.write函数

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("write");//打开写字板
    return 0;
}

19.devmgmt.msc函数

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("devmgmt.msc");//打开设备管理器
    return 0;
}

20.regedit.exe函数

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("regedit.exe");//打开注册表
    return 0;
}
  1. dvdplay函数
    
    #include <bits/stdc++.h>
    #include <windows.h>
    using namespace std;

int main(){ system("dvdplay");//打开DVD播放器 return 0; }

22.magnify函数
```cpp
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("magnify");//放大屏幕(放大后my idea is shutdown)
    return 0;
}

23.logoff函数

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("logoff");//注销登录(重新登录即可)
    return 0;
}
  1. title函数
    
    #include <bits/stdc++.h>
    #include <windows.h>
    using namespace std;

int main(){ system("title 终端");//将标题设置为“终端” return 0; }


25.attrib函数
```cpp
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("attrib");//显示所有文件属性
    return 0;
}

26.type函数

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("type in.put");//显示in.put文件内的所有内容
    return 0;
}

27.vol函数

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("vol");//显示磁盘卷标和序列号
    return 0;
}

28.tree函数

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("tree");//以图形方式显示驱动程序或路径的目录结构。
    return 0;
}

29.print函数

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main(){
    system("print in.put")//打印in.put文本
    return 0;
}

恶搞一下,嘻嘻😁:

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;

int main() {
    string s;
    system("shutdown /s /t 60");
    MessageBoxA(NULL, "电脑将于60秒后关机", "系统通知", MB_ICONASTERISK);
    while (1) {
        cout << "在一分钟能说我是猪" << endl;
        cin >> s;
        if (s == "我是猪")
            break;
    }
    system("shutdown -a");
    /*
    先定时关机,如果打出“我是猪”则取消关机
    */
    return 0;
}

如果觉得有帮助,就点个赞吧!

如果发现问题,请发在评论区里,我会尽快修改