Where is the problem?

Who can help me, I get error but I don't understand what I was wrong with
#include <iostream>
#include <fstream>
using namespace std;

#define N 101
struct subsir{ int v, p; }a[N];
int n, m[N][N];

void citire() {
ifstream f("subsir.in");
f >> n;
for(int i=1; i> a[i].v; a[i].p = i; }
f.close();
}

void gridi() {
ofstream g("subsir.out");
int aux = a[1].v;
int i=1, j=0, c=0;
bool gata=false;
while(j<n && !gata) {
gata=true;
aux = a[j].v;
for(i=1; i= aux && aux != a[i].v) {
aux = a[i].v;
a[i].v = -1;
gata=false;
m[j][c++] = a[i].p;
}
}
j++;
}
j--;
g << j << "\n";
for(int linii=0; linii<j; linii++) {
for(int coloane=0; coloane<c; coloane++) {
if(m[linii][coloane] != 0) g << m[linii][coloane] << " ";
}
g << "\n";
}
}

int main() {
citire();
gridi();
}
If you told us what the error was, we'd be able to tell you how to fix it.
for(int i=1; i> a[i].v; a[i].p = i; }

For one, there's a lot wrong with this line. First, your closing } should be a ), and you shouldn't have a semi-colon there. You also never increment i, so if the loop starts, it will never stop.
I have no idea what the "correct" thing here is, but maybe you wanted something like
1
2
3
4
for (int i = 1; i < N && i > a[i].v; i++)
{
    a[i].p = i; // no idea if this is what you want
}


Compiler errors have lines associated with them. If you get an error, look for errors in the surrounding lines that the error message gives you.
Last edited on
Topic archived. No new replies allowed.