#include<bits/stdc++.h>
using namespace std;
const int maxn=1000005;
#define int long long
#define rep(i,j,k) for(int i=(j);i<=(k);++i)
#define dow(i,j,k) for(int i=(j);i>=(k);--i)
#define pr pair
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
int t,n,m,k;
inline int max(int a,int b) {
return a>b?a:b;
}
inline int min(int a,int b) {
return a>b?b:a;
}
inline int read() {
int x=0;
char ch=getchar();
while(1) {
if (ch>='A'&&ch<='F') {
x=ch-'A'+10;
return x;
} else if(ch>='0'&&ch<='9') {
x=ch-48;
return x;
}
ch=getchar();
}
}
int gp(int x,int y) {
// if(y==x)
// return x;
int t;
while((t=rand())<=0)
srand(time(0));
return t%(y-x+1)+x;
}
int gp() {
int t;
while((t=rand())<=0)
srand(time(0));
return t;
}
char ope[]= {'+','-','*','/','^'};
signed main() {
ios::sync_with_stdio(false),cin.tie(NULL);
freopen("data.in","w",stdout);
srand(time(0));
t=gp(1,20);
cout<<t<<endl;
while(t--) {
n=gp(1,7);
int cont=0;
rep(i,1,n) {
while(cont>=0&&rand()>20000) {
cont++;
cout<<"(";
}
cout<<(char)('A'+i-1);
while(cont>0&&rand()>20000) {
cont--;
cout<<")";
}
if(i!=n)
cout<<ope[gp()%5];
}
while(cont>0) {
cont--;
cout<<")";
}
cout<<'#'<<endl;
}
return 0;
}
标签:ch,cont,中缀,int,--,&&,代数,表达式,define
From: https://www.cnblogs.com/WXk-k/p/17755507.html