我用帖子存一下代码,不用点进来

jjj0 three bodys 2023-03-07 20:30:19 0

#include<bits/stdc++.h> using namespace std; int n; int a[15100]; int b = 1; int empty(){ if (b == 1){ return 1; }else{ return 0; } } void in(int q){ while (1){ if (empty() == 1 or a[b] > q){ a[b] = q; b++; return; }else{ b--; } } return; } void out(){ b--; return; } int main(){ cin>>n; long long s = 0; int k = 0; int hi; for (int i = 1;i <= n;i++){ cin>>hi; in(hi); k = b - 1; s += k; } cout<<s; return 0; } 山峰


#include<bits/stdc++.h> using namespace std; char a[250]; int first = 1; int last = 1; int main(){ string n; int k; cin>>n; k = n.size(); for (int i = 1;i <= k;i++){ if (n[i - 1] == '(' or n[i - 1] == '['){ a[last] = n[i]; last++; }else{ if (n[i] == ']' and a[first] == '['){ first++; last--; }else if (n[i] == ')' and a[first] == '('){ first++; last--; }else{ cout<<"Wrong"; return 0; } } } cout<<"OK"; return 0; } 括号匹配


#include<bits/stdc++.h> using namespace std; int n; int a[9999]; int main(){ cin>>n; for (int i = 1;i <= n;i++){ cin>>a[i]; } if (n == 1){ cout<<5060<<" "<<5060; return 0; } int little = 9999999; int big = -99999; for (int i = 1;i <= n;i++){ if (a[i] > big){ big = a[i]; }else if (a[i] < little){ little = a[i]; } } cout<<big<<" "<<little; return 0; } 寻找最值

{{ vote && vote.total.up }}

共 3 条回复

CPP 刷题王
#include<bits/stdc++.h>
using namespace std;
int n;
int a[15100];
int b = 1;
int empty() {
	if (b == 1) {
		return 1;
	} else {
		return 0;
	}
}
void in(int q) {
	while (1) {
		if (empty() == 1 or a[b] > q) {
			a[b] = q;
			b++;
			return;
		} else {
			b--;
		}
	}
	return;
}
void out() {
	b--;
	return;
}
int main() {
	cin >> n;
	long long s = 0;
	int k = 0;
	int hi;
	for (int i = 1; i <= n; i++) {
		cin >> hi;
		in(hi);
		k = b - 1;
		s += k;
	}
	cout << s;
	return 0;
}
山峰
jjj0 three bodys

emm..... 第一次用这个存代码,不用在意这些细节(本来以为会直接乱码)

CPP 刷题王

系统提示:代码是不是得格式化一下?