0分求助!
查看原帖
0分求助!
1004888
Genius_physicist楼主2023/7/14 08:54

个人还是小学生,请多指教

#include <bits/stdc++.h>
using namespace std;
int cnt[20005], res[20005], n, N = 1;
bool ans;
int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> cnt[i];
	}
	for(int i = 1; i <= n; i++)
	{
		cnt[N] = -1;
		for(int j = 1;j <= n; j++)
		{
			ans = cnt[j];
			if(ans == cnt[j + 1])
			{
				cnt[j] = -1;
				res[N] = j;
			}
			N++;
		}
	}
	N = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 0; res[N] > -1; j++)
		{
			cout << res[N] << " ";
		}
		cout << "\n";
	}
	return 0;
}
2023/7/14 08:54
加载中...