跳到正文

科技·工程

LL 语法(9. 8 更新)

#SUSPENDED#约 3 分钟
原文
文章信息与版本

文章信息

发布
2025年9月8日
收录
2025年12月12日
更新
2026年11月14日
篇幅
约 3 分钟

版本

  1. v1当前

编译器(C++)

C++
#include <bits/stdc++.h>
#define int long long
using namespace std;

string s;
vector<string> p;
string ope;
map <string, int> bianliang;

signed main(){
	while (cin >> s){
		if (s == "RUN")
			break;
		p.push_back(s);
	}
	for (int x = 0; x < p.size(); x++){
		string code = p[x];
		if (ope == "in"){
			int inputcode;
			cin >> inputcode;
			bianliang[code] = inputcode;
			ope = "";
		}
		if (ope == "out"){
			if (code == "NL")
				cout << endl;
			else if (code[0] == '"' && code[code.size() - 1] == '"')
				cout << code;
			else
				cout << bianliang[code];
			ope = "";
		}
		if (ope == "int"){
			int now = 0;
			int flag = 0;
			string now_bl;
			for (int i = 0; i < code.size(); i++){
				if (code[i] == '='){
					flag = 1;
					continue;
				}
				if (flag == 0)
					now_bl += code[i];
				else
					now = now * 10 + code[i] - '0';
			}
			bianliang[now_bl] = now;
			ope = "";
		}
		if (code == "in")
			ope = code;
		if (code == "out")
			ope = code;
		if (code == "int")
		ope = code;
	}
	return 0;
}

运行方法

  • 输入代码。
  • 输入 RUN 表示运行。
  • 输入你要对程序进行的输入。

具体语法(仅目前支持)

  • 定义整形变量 x(0≤x<263)x(0\le x<2^{63}),并赋值为 1010,可以不赋值(默认为 00)。
代码
int x=10 //定义 x=10
int y //定义 y=0
  • 输出字符串、变量、换行。
代码
out "luogu" //输出 luogu
out NL //输出换行
int x=100
out x //输出 x,即 100
  • 输入整形变量
代码
int x
in x //输入 x
out x
in y //输入 y(若没有定义,则自动定义)
out y

洛谷题目代码

https://www.luogu.com.cn/problem/B2002

代码
out "Hello,World!"

https://www.luogu.com.cn/problem/B2025

代码
out "  *"
out NL
out " ***"
out NL
out "*****"
out NL
out " ***"
out NL
out "  *"
原文