I don't know how to finish...give a lot of error's

I need to make a program to calculate a determinant of order n>1,and test if a square matrix with elements real numbers is invertible or not.

I made some of the program but have soem errors on of them is expecte primary-expresion before "int"..

This is what i did:

#include "stdafx.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <conio.h>
using namespace std;

typedef vector<double>Vect;
typedef vector<Vect>Matr;

int fact(int a);

int main()
{

int i;
int numarare = 0;
int nr = 0;
cout << " Give the matrix order :\n";
cin >> nr;

cout << " Give the square matrix :\n";
Vect rand(nr);
Vect determinant;
Matr a;
int produs = 1;
int determ = 0;
int ve1 = 0;

for(i = 0; i < nr; i++)
{
for(int j = 0; j < nr; j++)
{
if(j<(nr-1))
cout << " enter elemnt\n";
else cout << " enter last element of this place\n";
cin >> rand[j];
}
a.push_back(rand);
}




vector<int>vec;
for(i = 1; i <= nr; i++)
vec.push_back(i);
vector<int>::iterator iter1 = vec.begin();
vector<int>::iterator iter2 = vec.end();


for(i = 0; i < fact(nr); i++)
{
vector<int>vec1(nr);
copy(vec.begin(), vec.end(), vec1.begin());

for(int i = 0; i < vec1.size(); i++)
{

for(int j = i; j < vec1.size(); j++)
{
if(vec1[j]<vec1[i])
numarare++;
}
}

for(int w = 0; w < nr; w++)
{
ve1 = (vec1[w])-1;
int produs *= (a[w][ve1]);
}
if(numarare%2!=0)
produs = (- produs);

determinant.push_back(produs);

numarare = 0;
produs = 1;
next_permutation(iter1, iter2);
cout << endl;
}

for(int x = 0; x < determinant.size(); x++)
{
determ += determinant[x];
}

for(i = 0; i < nr; i++)
{
cout << endl;
for(int j = 0; j < nr; j++)
{
cout << a[i][j] << " ";
}
}
cout << endl;

if(determ==0)
Cout<<”square matrix is not invertible”;
else
cout<<”matrix is invertible


_getch();
return 0;
}

int fact(int a)
{
if(a<=1)
return a;


Here: ve1 = (vec1[w])-1;
int produs *= (a[w][ve1]);
..expected primary-expression before "int"
Last edited on
Please use code tags. Thet looks like "<>".

What line gives you this error?

EDIT: in:
1
2
3
4
if(determ==0)
Cout<<”square matrix is not invertible”;
else
cout<<”matrix is invertible

1) You should use ", not .
2) it's "cout", not "Cout"
3) You forgot ";" at the end
fix:
1
2
3
4
if(determ==0)
cout<<"square matrix is not invertible";
else
cout<<"matrix is invertible";
Last edited on
The "wrong sort of quotes" suggests the code was edited using a word processor rather than a text editor.

It's definitely worthwhile using a proper text editor, not just because of issues like this, but also because of other features such as syntax highlighting, matching of braces, code folding etc. which you will find in a good code editor.
Topic archived. No new replies allowed.