Invalid types for array

Hello. I'm trying to compile this program and i have some strange issue that i can't fix. Please help me!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
using namespace std;

int dividing(int * T, int N, int l, int p)
{
  int Rn = 0;
  int Ln = 0;
  int * R = new int[N-1];
  int * L = new int[N-1]; 
  
  //if(N==1) return;
  for(int i=l; i<p; i++)
    {
      if(T[0]>T[i])
	{
	  L[Ln] = T[i];
	  Ln++;
	}
      else
	{
	  R[Rn] = T[i];
	  Rn++;
	}
    }
  T[Ln+1]=T[0];
  
  for(int i=0;i<Ln;i++)
    {
      T[i]=Ln[i];
    }
  for(int i=(p-Rn)+1;i<N;i++)
    {
      T[i]=Rn[i];
    }
  return p-Rn;
  delete R;
  delete L;
  
}
void sort(int * T, int N, int l, int p)
{
  int q;
  if(q>=1)
    {
      q = dividing(T, N, l, p);
      sort(T, N, l, q);
      sort(T, N, q+1, N);
    }
}

      

int main()
{
  int T[7] = {3,5,2,1,6,7,8};
  sort(T,7,0,7);
  for(int i=0;i<7;i++)
    cout << "[" << T[i] << "] ";
}


sortowanie.cpp: In function ‘int dividing(int*, int, int, int)’:
sortowanie.cpp:29:16: error: invalid types ‘int[int]’ for array subscript
sortowanie.cpp:33:16: error: invalid types ‘int[int]’ for array subscript

You will probably figure out what this program should do and i know this isn't good and i will probably have another problems with this but i want to try challenge them by myself so I ask you to help me only with this one error. Thanks.
Last edited on
Ln and Rn aren't arrays.
I think you meant to use L and R, and not Ln and Rn.
Thanks a lot. Next stupid mistake. This compiler outputs are really non-intuitive for me... I hope that one day i won't have that kind of problems. This program isn't working the way i want it to work and this time i will give up my idea. Thanks again.
Topic archived. No new replies allowed.