文章

71

粉丝

97

获赞

5

访问

16.3k

头像
明明的随机数 为什么output exceed
我要提问
发布于2024年3月23日 16:39
阅读数 122

#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<ctime>
using namespace std;

const int maxn = 105;
int arr[maxn];
int record[1005];

int main() {
    int n;
    
        memset(record, 0, sizeof(record));
        int j = 0;
        for (int i = 0; i < n; i++) {
            int num = rand() % 1000 + 1;
            record[num]++;
            if (record[num] == 1) {
                arr[j++] = num;
            }
        }
        cout << j << endl;
...

登录查看完整内容


登录后发布评论

2 条评论
snake
2024年3月23日 18:19

你这代码输入都没有啊。。。

注意看题目样例

赞(0)

DestinyCares+++ : 回复 snake: 不是随机产生的吗

2024年3月23日 18:43