如何科学的食用$\LaTeX$

· · 个人记录

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

#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; 
    }
}