1 #include<iostream>
2 #include<string.h>
3 using namespace std;
4 #define N 100
5 class stack
6 {
7 char s[N];
8 int top;
9 public:
10 stack() { top = -1; }
11 void push(char p) { top++; s[top] = p; }
12 void pop() { top--; }
13 char seek() { return s[top]; }
14 bool empty() { if (top == -1)return true; return false; }
15 };
16 void check(char* temp)
17 {
18 stack p;
19 if (temp[0] == ')' || temp[0] == ']')
20 cout << "no" << endl;
21 else
22 {
23 for (int i = 0; i < strlen(temp); i++)
24 if (temp[i] == '(' || temp[i] == '[')
25 p.push(temp[i]);
26 else if (temp[i] == ')' || temp[i] == ']')
27 {
28 if (temp[i] == ')'&&p.seek() == '(')
29 p.pop();
30 else if(temp[i] == ']'&&p.seek() == '[')
31 p.pop();
32 else
33 {
34 cout << "no" << endl;
35 return;
36 }
37 }
38 if(p.empty())
39 cout << "yes" << endl;
40 else
41 cout << "no" << endl;
42 }
43 }
44 int main()
45 {
46 char s[10];
47 int n; cin >> n;
48 for (int i = 0; i < n; i++)
49 {
50 cin >> s;
51 check(s);
52 }
53 return 0;
54 }
1 #include<iostream>
2 #include<cstring>
3 #define maxsize 10000
4 using namespace std;
5 int a[maxsize];
6 int main()
7 {
8
9
10 int m;
11 cin >> m;
12 a[1] = 1;
13 long long delta = 0, pos = 1;//pos为此刻进位到哪,由于delta用于进位累加,故long
14 for (int i = 1; i <= m; i++)//让a[]从1乘到m
15 {
16 delta = 0;
17 for (int j = 1; j <= pos; j++)
18 {
19
20 a[j] = a[j] * i + delta;
21 delta = a[j] / 10;//个位之前
22 a[j] = a[j] % 10;//个位
23
24 }
25 if (delta != 0)//进位
26 {
27 while (delta) {//对进位进行循环,确保进位大于9时完全进位上去
28 a[pos + 1] = delta % 10;
29 delta = delta / 10;
30 pos = pos + 1;
31 }
32 }
33 }
34
35
36
37 for (int i = pos; i >= 1; i--)
38 {
39 cout << a[i];
40 }
41
42 }