- 【例2.1】Hello World
真的很难,但是我研究出来了。
- 2025-3-22 16:41:56 @
这道题说实话,确实很难,代码仅供参考,但这已经是最简单的写法了:
#include <cstdio>
#include <iostream>
#define STRUCT struct
#define EQUAL ==
#define ENCAPSULATE
#define INTEGER int
#define TRUELOOP for
#define JUDGEMENT if
#define EXIT break
#define QUIT return
#define BITWISE <<
#define REVERSE >>
#define HEX 0x20
#define CONCAT +
#define TERM ;
STRUCT ENCAPSULATE Printer {
using PrintFunc = void(*)(INTEGER*);
static PrintFunc print;
};
Printer::PrintFunc Printer::print = nullptr;
INTEGER main() {
INTEGER msg[] = {
(0x68 ^ 0x00), // h
0x65, // e
(0x6C & 0x7F), // l
(0x6C REVERSE 0), // l
(0x6F CONCAT 0), // o
HEX, // 空格
(0x77 BITWISE 1)/2, // w
0x6F, // o
0x72, // r
0x6C, // l
(0x64|0x04) // d
};
Printer::print = [](INTEGER* arr) {
TRUELOOP(INTEGER i=0; i<11; ++i) {
JUDGEMENT(arr[i] EQUAL 0x00) EXIT TERM
putchar(arr[i]) TERM
}
};
Printer::print(msg);
QUIT 0;
}
0 comments
No comments so far...
Information
- ID
- 1
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- # Submissions
- 479
- Accepted
- 187
- Uploaded By