跳到正文

个人记录

如何科学的食用$\LaTeX$

xutongwei约 2 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年6月7日
篇幅
约 2 分钟

版本

  1. v1当前

转载自 如何科学的食用LaTeX\LaTeX

C++
#include<bits/stdc++.h>
using namespace std;
string q[1000];
int i;
string a[]= {
	"\\tiny",
	"\\scriptsize",
	"\\footnotesize",
	"\\small",
	"\\normalsize",
	"\\large",
	"\\Large",
	"\\LARGE",
	"\\huge",
	"\\Huge"
};
void f(int x) {
	if(x==i) return;
	if(q[x]=="?"||q[x]=="!") cout<<a[9];
	else cout<<a[rand()%9]<<' ';
	cout<<"\\texttt{";
	if(q[x]=="_") cout<<'\\';
	cout<<q[x];
	cout<<"}";
	if(rand()%4) {
		if(rand()%3==0) cout<<'_';
		else if(rand()%3==0) cout<<'^';
		cout<<"{";
		f(x+1);
		cout<<'}';
	} else f(x+1);
}
int main() {
	freopen("LateX.in", "r", stdin);
	freopen("LateX.out", "w", stdout);
	srand(time(0));
	for(;;) {
		for(i=0;; i++) {
			cin>>q[i];
			if(q[i]=="$") break;
		}
		cout<<'$';
		f(0);
		cout<<'$'<<endl;
		break; 
	}
}
原文