样例对,一交就wa,有没有好心人帮帮忙o(╥﹏╥)o
查看原帖
样例对,一交就wa,有没有好心人帮帮忙o(╥﹏╥)o
1580813
lucykya楼主2024/11/20 21:31

代码:

#include<bits/stdc++.h>

using namespace std;

int a[110];

int main(){

	int n,q;
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> a[i];
	}
	cin >> q;
	for(int i = 1;i <= q;i++){
		int l,r;
		cin >> l >> r;
		for(int k = l+1;k <= r;k++){
			if (a[k] < a[k - 1]){
				int temp = a[k];
                a[k] = a[k - 1];
                a[k - 1] = temp;
			}
		}
	}
	for(int i = 1;i <= n;i++){
		cout << a[i] << " ";
	}
	return 0;
}

不太会格式o(╥﹏╥)o

2024/11/20 21:31
加载中...