文章

34

粉丝

18

获赞

6

访问

12.3k

头像
整数去重 题解:最清楚版
P2021
发布于2024年6月28日 19:34
阅读数 634

m的一开始没有看数组的范围,少看了一个0,本来想用B数组作为复制的,结果直接输出可以ac

#include <iostream>
#include <string.h>

using namespace std;

const int N = 2e4 + 10;
int a[N],b[N];
bool f[N];
int n;
 
int main(){
    while(cin >> n){
        memset(f,false,sizeof(f));
        int j = 0;
        for(int i = 0;i < n;i ++){
            cin >> a[i];
            if(!f[a[i]]){
                cout << a[i] << " ";
            }
            f[a[i]] = true;
        }
        cout << endl;
    }
    return 0;
}

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发