用set过了,不知道另一种方法为什么55分
查看原帖
用set过了,不知道另一种方法为什么55分
383027
Torbllino楼主2023/11/13 19:51
#include<bits/stdc++.h>
using namespace std;
int b[10010];
int a[10010];
int main(){
	int n, s = 0;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	for(int i = 1; i <= n; i++){
		for(int j = i + 1; j <= n; j++)
		{
			if(a[i] == a[j])
			{
				b[j] = 1;
			}
		}
	}
	
	for(int i = 1; i <= n; i++)
	{
		if(b[i] == 0){
			s++;
		}
	}
	cout << s << endl;
	return 0;
}

(原谅我懒得要死,不用scanf)

2023/11/13 19:51
加载中...