新编程语言S++
2024-08-26 17:35:45
发布于:广东
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;
string model,sact1,sact2,sact3,sact4,sact5,f;
long long x,y,z;
bool flag;
double li;
map<string,string> m;
int s_i(string a){
long long l;
l=stoi(a);
return l;
}string i_s(long long a){
string l;
l=to_string(a);
return l;
}double maths(int x,string f,int y){
flag = 0;
if(!x and y)return 0;
else if((f == "/" or f == "//" or f == "%")and y == 0)return -1;
else if(f=="+")return x+y;
else if(f=="-")return x-y;
else if(f=="*")return x*y;
else if(f=="/")return x*1.0/y;
else if(f=="//")return x/y;
else if(f=="^")return pow(x,y);
else if(f=="%")return x%y;
}void print(){
cin >> sact1;
if(sact1=="maths"){
cin >> x >> f >> y;
if(maths(x,f,y)==-1)cout << "除数不能为0" <<endl;
else cout << i_s(maths(x,f,y)) << endl;
return;
}else if(sact1 == "value"){
cin >> sact2;
cout << m[sact2] << endl;
}else if(sact1 == "while"){
cin >> x >> y >> z;
for(int i=x;i<=y;i+=z){
cout << i << " ";
}cout << endl;
}else if(sact1 == "random"){
cin >> x >> y;
x = rand()%(y-x+1)+x;
cout << x << endl;
}else{
cout << sact1 << endl;
return;
}
}void print2(){
getline(cin,sact1);
cout << sact1 << endl;
}
void value(){
cin >> sact1 >> sact2;
if(sact2 == "maths"){
cin >> x >> f >> y;
if(maths(x,f,y)==-1){
cout << "除数不能为0,变量值默认设置为0" << endl;
m[sact1] = "0";
}
else m[sact1] = i_s(maths(x,f,y));
}else if(sact2 == "="){
cin >> sact3;
m[sact1] = sact3;
}else if(sact2 == "++"){
x = s_i(m[sact1])+1;
m[sact1] = i_s(x);
}else if(sact2 == "--"){
x = s_i(m[sact1])-1;
m[sact1] = i_s(x);
}else if(sact2 == "+="){
cin >> sact3;
x = s_i(m[sact1])+s_i(sact3);
m[sact1] = i_s(x);
}else if(sact2 == "-="){
cin >> sact3;
x = s_i(m[sact1])-s_i(sact3);
m[sact1] = i_s(x);
}else if(sact2 == "*="){
cin >> sact3;
x = s_i(m[sact1])*s_i(sact3);
m[sact1] = i_s(x);
}else if(sact2 == "/="){
cin >> sact3;
if(sact3=="0"){
cout << "除数不能为0,变量值不变" << endl;
return;
}x = s_i(m[sact1])/s_i(sact3);
m[sact1] = i_s(x);
}else if(sact2 == "^="){
cin >> sact3;
x = pow(s_i(m[sact1]),s_i(sact3));
m[sact1] = i_s(x);
}else if(sact2 == "random"){
cin >> x >> y;
x = rand()%(y-x+1)+x;
m[sact1] = i_s(x);
}
}void c_time(){
cin >> x >> sact1;
if(sact1 == "s")y=1000;
else if(sact1 == "m")y=60000;
else if(sact1 == "h")y=3600000;
x = x*(y/1000);
z = x;
while(x){
y = (z-x)*100;
system("cls");
cout << "-----------------------------欢迎使用S++---------------------------" << endl;
cout << "还剩"<< x<<"秒"<< endl;
for(int i=0;i<y/z;i++)cout << "0";
for(int i=0;i<100-y/z;i++)cout << ".";
cout << " " << y/z << "%"<< endl;
Sleep(912);
x--;
}system("cls");
for(int i=0;i<100;i++)cout << "0";
cout << " "<< 100 << "%" << endl;
cout << "倒计时结束";
Sleep(500);
system("cls");
cout << "-----------------------------欢迎使用S++---------------------------" << endl;
}void ntime(){
auto now = std::chrono::high_resolution_clock::now();
std::time_t now_c = std::chrono::system_clock::to_time_t(now);
std::cout << "当前时间: " << std::ctime(&now_c) << endl;
}bool is_flag = 1;
void is_run(){
cin >> sact1;
if(sact1=="bool" and is_flag){
cin >> sact2;
if(sact2 == "true")return;
else if(sact2 == "false")is_flag = 0;
}else if(sact1=="value" and is_flag){
cin >> sact2 >> sact3 >> sact4;
if(sact3 == "=="){
if(m[sact2] != sact4){
is_flag = 0;
}else if(m[sact2] == sact4)return;
}else if(sact3 == "!="){
if(m[sact2] == sact4){
is_flag = 0;
}else if(m[sact2] != sact4)return;
}else if(sact3 == "<"){
if(s_i(m[sact2]) > s_i(sact4)){
is_flag = 0;
}else if(s_i(m[sact2]) < s_i(sact4))return;
}else if(sact3 == ">"){
if(s_i(m[sact2]) < s_i(sact4)){
is_flag = 0;
}else if(s_i(m[sact2]) > s_i(sact4))return;
}else if(sact3 == "<="){
if(s_i(m[sact2]) > s_i(sact4)){
is_flag = 0;
}else if(s_i(m[sact2]) <= s_i(sact4))return;
}else if(sact3 == ">="){
if(s_i(m[sact2]) < s_i(sact4)){
is_flag = 0;
}else if(s_i(m[sact2]) >= s_i(sact4))return;
}
}else if(sact1 == "end"){
is_flag = 1;
}
}void help(){
cout << "-----------------------------欢迎使用S++---------------------------" << endl;
cout << "1.print maths 1 + 1 计算并输出1+1的结果,运算符有+ - * / // % ^" << endl;
cout << "2.value a = 0 将a并赋值为字符串0,除了=还有++ -- += -= *= /= ^=" << endl;
cout << "3.print only one 输出空格之前的only" << endl;
cout << "4.print: I am S++ 输出除print:以外的所有内容" << endl;
cout << "5.print value a 输出变量a所对应的值" << endl;
cout << "6.if bool false 因布尔值为否,后面的代码将不会执行直到出现is end" << endl;
cout << "7.if value a == 0判断条件是否成立,不成立则如上一行提示执行。" << endl;
cout << "8.判断符号有 == != <= >= < >" << endl;
cout << "9.if end 解除if造成的代码不执行,这行代码后面代码将会执行" << endl;
cout << "10.clock 1 m 倒计时1分钟,单位有s,m,h" << endl;
cout << "11.time 输出当前时间。" << endl;
cout << "12.help 如果代码不会写,可以调出教程" << endl;
cout << "13.clean 清空所有输入和输出,但数据不会被删" << endl;
cout << "14.如果写完代码之后没有相对应的反应,请检查是否写错或者或有if条件不成立" << endl;
cout << "15.print while 1 1000 2 输出从1到1000的数,步长为2" << endl;
cout << "16.print random 1 100 输出1到100之中的随机整数" << endl;
cout << "16.value a random 1 100 将变量a赋值为1到100的随机数" << endl;
cout << "17.value a maths 1 + 1 将变量a赋值为1+1的结果" << endl;
cout << "18.end 结束程序" << endl;
}void clean(){
system("cls");
cout << "-----------------------------欢迎使用S++---------------------------" << endl;
}
int main(){
srand(time(0));
help();
while(true){
cin >> model;
if(model == "end")break;
else if(model == "print" and is_flag)print();
else if(model == "print:" and is_flag)print2();
else if(model == "value" and is_flag)value();
else if(model == "clock" and is_flag)c_time();
else if(model == "time" and is_flag)ntime();
else if(model == "if")is_run();
else if(model == "help")help();
else if(model == "clean")clean();
}
return 0;
}
全部评论 6
新版已经写出来了
https://www.acgo.cn/discuss/rest/3179120小时前 来自 广东
0作者正在更新新的 c## 需等待 最少一周
1周前 来自 广东
0要用DEV几的版本才运行得起来?
2024-08-27 来自 福建
0chatgpt好用吗(
2024-08-27 来自 广东
0我才没用
2024-08-27 来自 广东
1证据说话
2024-08-27 来自 广东
0干嘛诽谤别人你有证据吗
2024-08-27 来自 广东
0
豪玩
2024-08-27 来自 广东
0nb
2024-08-27 来自 广东
0
有帮助,赞一个