Question:
C++ Compiling Help!!!!!!!!!!!!!!!!!!!!?
2008-12-04 23:12:55 UTC
I am trying to compile this program; however, I am getting the following errors:
InsertionSort.cpp:35: error: expected constructor, destructor, or type conversion before '<<' token
InsertionSort.cpp:35: error: expected `,' or `;' before '<<' token
InsertionSort.cpp:36: error: expected declaration before '}' token


#include
using namespace std;

#define MAX_LIST_LEN 2000


int main(){

int n, j, a[j], temp, L = 2;
double list[MAX_LIST_LEN];

cout << "Enter list length (must be less than or equal to "
<< MAX_LIST_LEN << "): ";
cin >> n;
cout << "Enter " << n << " numbers:" << endl;
for(j=0; j cin >> list[j];
}

while (L <= n)
{
j = L;
while ((j>=2) && (a[j] < a[j-1]))
{

temp = a[j];
a[j] = a[j-1];
a[j-1] = temp;
j--;
L--;
}
}
}

cout << a[j];
}
cout << endl;

return(0);
}


I am new to c++, so can someone please tell me how to fix this problem? Thanks.
Three answers:
Bob S
2008-12-04 23:17:06 UTC
what is line 35 and 36 of insertionSort.cpp
2008-12-05 00:52:17 UTC
1) "int j, a[j]" This was not the greatest idea ever.

No really, this is plainly stupid.





2)Too many curly brackets.
Twestuvs
2008-12-04 23:37:56 UTC
you have too many closing squigly bracket things "}" after the L--; line.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...