猫史档案馆


C++指令控制台程序

用户:RendexORERendexORE查看:2 回复:4 评论:2 创建时间:2024-07-06T11:40:37


#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main()
{
    string command,value;
    bool cls;
    while(true)
    {
		if(cls==false)
		{
			cout<<">>>";
		}
		cin>>command>>value;
		if(cls==true)
		{
			system("clear");
		}
		if(command=="out")
		{
			cout<<value<<endl;
		}
		if(command=="@out")
		{
			if(value=="off")
			{
				cls=true;
			}
			else
			{
				if(value=="on")
				{
					cls=false;
				}
				else
				{
					cout<<"Error:Not exist value"<<endl;
				}
			}
		}
		if(command=="clean"&&value=="\\")
		{
			system("clear");
		}
		if(command=="sys")
		{
			system(value.c_str());
		}
	}
}

在此程序中,输入"clean \"清屏,输入"out yyy"输出,输入"@out off/on"开/关命令输出,输入"sys yyy"调用系统指令yyy(仅在Lunix下有效)

以下是Windows版本:

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main()
{
    string command,value;
    bool cls;
    while(true)
    {
		if(cls==false)
		{
			cout<<">>>";
		}
		cin>>command>>value;
		if(cls==true)
		{
			system("cls");
		}
		if(command=="out")
		{
			cout<<value<<endl;
		}
		if(command=="@out")
		{
			if(value=="off")
			{
				cls=true;
			}
			else
			{
				if(value=="on")
				{
					cls=false;
				}
				else
				{
					cout<<"Error:Not exist value"<<endl;
				}
			}
		}
		if(command=="clean"&&value=="\\")
		{
			system("cls");
		}
		if(command=="sys")
		{
			system(value.c_str());
		}
	}
}


回复

上一页1 页 / 共 1下一页
RendexORERendexORE

运行图片(Lunix版本):

center_image

点赞0


评论


RendexORERendexORE

控制台程序名称:rsl

版本:1.1.2

点赞0


评论


RendexORERendexORE

Lunix更新版本:

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main()
{
    string command,value;
    bool cls;
    while(true)
    {
		if(cls==false)
		{
			cout<<">>>";
		}
		cin>>command>>value;
		if(cls==true)
		{
			system("clear");
		}
		if(command=="out")
		{
			cout<<value<<endl;
		}
		if(command=="@out")
		{
			if(value=="off")
			{
				cls=true;
			}
			else
			{
				if(value=="on")
				{
					cls=false;
				}
				else
				{
					cout<<"Error:Not exist value"<<endl;
				}
			}
		}
		if(command=="clean"&&value=="\\")
		{
			system("clear");
		}
		if(command=="sys")
		{
			system(value.c_str());
		}
		if(command=="apt-install")
		{
			system(("sudo apt install "+value).c_str());
		}
		if(command=="apt-remove")
		{
			system(("sudo apt remove "+value).c_str());
		}
		if(command=="downloads")
		{
			system(("wget "+value).c_str());
		}
		if(command=="rsl"&&value=="\\")
		{
			cout<<"rsl v1.1.2\nCopyright Rinson Tec 2024\n";
		}
	}
}

Windows更新版本:

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main()
{
    string command,value;
    bool cls;
    while(true)
    {
		if(cls==false)
		{
			cout<<">>>";
		}
		cin>>command>>value;
		if(cls==true)
		{
			system("cls");
		}
		if(command=="out")
		{
			cout<<value<<endl;
		}
		if(command=="@out")
		{
			if(value=="off")
			{
				cls=true;
			}
			else
			{
				if(value=="on")
				{
					cls=false;
				}
				else
				{
					cout<<"Error:Not exist value"<<endl;
				}
			}
		}
		if(command=="clean"&&value=="\\")
		{
			system("cls");
		}
		if(command=="sys")
		{
			system(value.c_str());
		}
		if(command=="downloads")
		{
			system(("wget "+value).c_str());
		}
		if(command=="rsl"&&value=="\\")
		{
			cout<<"rsl v1.1.2\nCopyright Rinson Tec 2024\n";
		}
	}
}

点赞0


评论


RendexORERendexORE

Lunix最新版本:

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main()
{
    string command,value;
    while(true)
    {
		cout<<">>>";
		cin>>command>>value;
		if(command=="out")
		{
			cout<<value<<endl;
		}
		if(command=="clean"&&value=="-")
		{
			system("clear");
		}
		if(command=="sys")
		{
			system(value.c_str());
		}
		if(command=="apt-install")
		{
			system(("sudo apt install "+value).c_str());
		}
		if(command=="apt-remove")
		{
			system(("sudo apt remove "+value).c_str());
		}
		if(command=="download")
		{
			system(("wget "+value).c_str());
		}
		if(command=="new-file")
		{
			system(("touch \""+value+"\"").c_str());
		}
		if(command=="edit")
		{
			system(("nano \""+value+"\"").c_str());
		}
		if(command=="delete")
		{
			system(("rm \""+value+"\"").c_str());
		}
		if(command=="new-fold")
		{
			system(("mkdir \""+value+"\"").c_str());
		}
		if(command=="kill-task")
		{
			system(("kill "+value).c_str());
		}
		if(command=="rsl"&&value=="-")
		{
			cout<<"rsl v1.1.2\nCopyright Rinson Tec 2024\n";
		}
	}
}

点赞0


评论