Dev-Cpp报错[Error] ld returned 1 exit status
事先说明一下,我把黑色的运行框关闭了也是一样的结果,应该是不因为有程序正在运行才返回[Error] ld returned 1 exit status的。
代码粘出,共大家帮忙检查
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<algorithm>
using namespace std;
#include<cstring>
using namespace std;
#include<iostream>
using namespace std;
const int MaxN = 1e4 + 10;
int tmax, tmin, d[MaxN], e[MaxN];
double tav;
int * fun3(int * const buf);
void dispArr(int *arr, int n);
const int arrlen = 195;
int Random() {
for (int i = 0; i < 195; ++i) {
d[i] = i + 1;
}
int index, temp, rest = 195;
for (int i = 0; i < 195; ++i) {
index = rand() % rest;
e[i] = d[index];
temp = d[index];
d[index] = d[rest - 1];
d[rest - 1] = temp;
rest--;
}
return Random();
}
int *fun3(int* const buf) {
if (buf == NULL) {
cerr << "error: null ptr @buf" << endl;
return NULL;
}
for (int i = 0; i < arrlen; i++) {
buf[i] = i;
}
return buf;
for (int i = 0; i <= arrlen; i++) {
buf[i] = 0;
}
}
void dispArr(int *arr) {
for (int i = 0; i < 195; i++) {
Random();
}
for (int i = 0; i <= 195; i++) {
arr[i] = 0;
}
}
double dt = 0.95;
int t = 0, a = 0, b[228], l = 8, S = 4, n[250], c[MaxN];
double sum = 0;
int mmcs() {
memset(n, 0, 250);
int *arr2 = new int[arrlen];
dispArr(arr2, arrlen);
delete arr2;
for (int i = 0; i <= 194; i++) {
b[i] = Random();
for (int i = 0; i <= 194; i++) {
d[i] = 0;
e[i] = 0;
}
}
for (int i = 195; i <= 227; i++) {
b[i] = 0;
}
for (int j = 0; j <= 100000; j++) {
for (int i = 226; i >= 0; i--) {
if (ceil(b[i] / 6) == i - 194) {
if (n[i] == S + l) {
b[i] = 0;
n[i] = 0;
} else {
n[i]++;
}
} else {
if (b[i + 1] == 0) {
b[i + 1] = b[i];
b[i] = 0;
}
}
}
t++;
for (int i = 226; i >= 0; i--) {
if (b[i] != 0) {
a = 1;
}
}
if (a == 0) {
break;
}
a = 0;
c[j] = t * dt;
cout<<c[j]<<endl;
}
t = 0;
}
int main() {
for (int i = 0; i <= 9; i++) {
Random();
mmcs();
for (int i = 0; i < 195; ++i) {
d[i] = 0;
e[i] = 0;
}
}
for (int i = 0; i <= 9; i++) {
sum += c[i];
}
for(int i=0;i<=9;i++){
tmax=0;
tmin=10000;
if(tmax<c[i]){
tmax=c[i];
}
if(tmin>c[i]){
tmin=c[i];
}
}
tav = sum / 10;
cout << "tmax=" << tmax << ",tmin=" << tmin << " tav=" << tav << endl;
return 0;
}
运行结果及报错内容
报错内容:}(没错,就是一个大括号)
具体存在于函数mmcs的最后一行:
int mmcs() {
memset(n, 0, 250);
int *arr2 = new int[arrlen];
dispArr(arr2, arrlen);
delete arr2;
for (int i = 0; i <= 194; i++) {
b[i] = Random();
for (int i = 0; i <= 194; i++) {
d[i] = 0;
e[i] = 0;
}
}
for (int i = 195; i <= 227; i++) {
b[i] = 0;
}
for (int j = 0; j <= 100000; j++) {
for (int i = 226; i >= 0; i--) {
if (ceil(b[i] / 6) == i - 194) {
if (n[i] == S + l) {
b[i] = 0;
n[i] = 0;
} else {
n[i]++;
}
} else {
if (b[i + 1] == 0) {
b[i + 1] = b[i];
b[i] = 0;
}
}
}
t++;
for (int i = 226; i >= 0; i--) {
if (b[i] != 0) {
a = 1;
}
}
if (a == 0) {
break;
}
a = 0;
c[j] = t * dt;
cout<<c[j]<<endl;
}
t = 0;
}
关闭了所有的运行框且尝试过重新编译,没有反应。
希望各位能够帮忙解答,谢谢!