跳到正文

算法·理论

运算符宏(iso646)、代用符号 和 三标符 学习笔记

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

文章信息

发布
2024年4月28日
收录
2025年12月12日
更新
2026年11月15日
篇幅
约 3 分钟

版本

  1. v1当前

不知道有什么用,但是还是学了。

编译命令:gcc a.c -o a -g -std=c95 -trigraphs 或者 g++ a.cpp -o a -g -std=c++98 -trigraphs

三标符

注:该内容在较高标准的 C/C++ 中以被弃用。

三标符系列表格:

  • { ⟶ ??<\lbrace\ \longrightarrow\ \texttt{??<}
  • } ⟶ ??>\rbrace\ \longrightarrow\ \texttt{??>}
  • [ ⟶ ??([\ \longrightarrow \ \texttt{??(}
  • ] ⟶ ??)]\ \longrightarrow \ \texttt{??)}
  • # ⟶ ??=\texttt{\#}\ \longrightarrow\ \texttt{??=}
  • \ ⟶ ??/\backslash\ \longrightarrow\ \texttt{??/}
  • ^ ⟶ ??’\longrightarrow\ \texttt{??'}
  • ∣ ⟶ ??!|\ \longrightarrow\ \texttt{??!}
  • ∼ ⟶ ??-\sim\ \longrightarrow\ \texttt{??-}

由于三标符在编译时期就被处理了,所以你可以:

C
#include <stdio.h>
int main() {
  // /blah blah tat tat tatt ????????????????/
  这一行不会导致编译错误?????/
    这一行仍然不会导致编译错误
  int a, b;
  scanf("%d%d", &a, &b);
  printf("%d", a + b);
  return 0;
}

而正确的写出 a+ba+b Problem 问题的代码。

【例题】

给定两个正整数 aa,bb,求 a+ba+b 的值。

【解答】

C
??=include <stdio.h>
??=define int long long
signed main() ??<
    int a, b;
    scanf("%lld%lld", &a, &b);
    printf("%lld??/n", a + b);
    return 0;
??>

代用符号

注:这个没有被移除。

pkirtJS.png

这个不会在编译时期处理。

【例题】

给定两个正整数 aa,bb,求 a+ba+b 的值。

【解答】

C
%:include <bits/stdc++.h>
%:define int long long
using namespace std;
signed main() <%
    int a, b;
    cin >> a >> b;
    cout << a + b;
    return 0;
%>

三标符和代用符号的混用

实测可行。

【例题】

给定两个正整数 aa,bb,求 a+ba+b 的值。

【解答】

C
%:include <stdio.h>
%:define int long long
signed main() ??<
    int a, b;
    scanf("%lld%lld", &a, &b);
    printf("%lld??/n", a + b);
    return 0;
%>

运算符宏(iso646)

咕咕咕。

原文