0

int t=4; int b=3; int e=5; range time =1..t; range bus=1..b; range ev=1..e; float soci[ev][bus][time]=[[[0.5,0.3,0.8,0.7], [0.5,0.3,0.8,0.7], [0.5,0.3,0.8,0.7]] [[0.5,0.3,0.8,0.7], [0.5,0.3,0.8,0.7], [0.5,0.3,0.8,0.7]] [ [0.5,0.3,0.8,0.7], [0.5,0.3,0.8,0.7], [0.5,0.3,0.8,0.7]] [ [0.5,0.3,0.8,0.7], [0.5,0.3,0.8,0.7], [0.5,0.3,0.8,0.7]] [ [0.5,0.3,0.8,0.7], [0.5,0.3,0.8,0.7], [0.5,0.3,0.8,0.7]]];

I was trying to initialize a three dimensional array in this manner . But here an error is showing unexpected '[' expecting ']'.How to get rid of this error?

haripriya
  • 21
  • 4

1 Answers1

0
int t=4; int b=3; int e=5; range time =1..t; range bus=1..b; 

range ev=1..e; 

float soci[ev][bus][time]=
[[[0.5,0.3,0.8,0.7], [0.5,0.3,0.8,0.7], [0.5,0.3,0.8,0.7]] ,[[0.5,0.3,0.8,0.7],
 [0.5,0.3,0.8,0.7], [0.5,0.3,0.8,0.7]] ,[ [0.5,0.3,0.8,0.7], [0.5,0.3,0.8,0.7],
  [0.5,0.3,0.8,0.7]] ,[ [0.5,0.3,0.8,0.7], [0.5,0.3,0.8,0.7], [0.5,0.3,0.8,0.7]] ,
  [ [0.5,0.3,0.8,0.7], [0.5,0.3,0.8,0.7], [0.5,0.3,0.8,0.7]]];
  
  execute
  {
    writeln(soci);
  }

works fine. You were missing some commas.

Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15