Новые сообщения · Правила  
  • Страница 1 из 1
  • 1
Модератор форума: Berestovskiy  
Форум ПРОГРАММИСТОВ » ПРОГРАММИРОВАНИЕ » С, C++ » Нужна помощь - динамический массив (срочно)
Нужна помощь - динамический массив
Есть такой код:
Code

static void solve_pde_multigrid( CompBuf *F, CompBuf *U , short iterations, int mins, int levels)
{
   CompBuf *D, *C;
   int xmax = F->x;
   int ymax = F->y;
     
   int i;    // index for simple loops
   int k;    // index for iterating through levels
   int k2;    // index for iterating through levels in V-cycles

   // 1. restrict f to coarse-grid (by the way count the number of levels)
   //   k=0: fine-grid = f
   //   k=levels: coarsest-grid
   int pix = CB_VAL;
   int cycle;
   int sx, sy;

   // given function f restricted on levels
   CompBuf* RHS[levels+1];
     
   // approximate initial sollutions on levels
   CompBuf* IU[10];
   // target functions in cycles (approximate sollution error (uh - ~uh) )
   CompBuf* VF[10];

   VF[0] = alloc_compbuf(xmax,ymax, pix, 1);
     
   RHS[0] = alloc_compbuf(xmax,ymax, pix, 1);
   //mirror_compbuf_data(F, RHS[0]);
   copy_compbuf_data(F, RHS[0]);
   IU[0] = alloc_compbuf(xmax,ymax, pix, 1);
   copy_compbuf_data(U, IU[0]);
   .......
                .......


Если в строке CompBuf* RHS[levels+1]; вместо levels+1 поставить 10 как это сделано ниже, то всё работает прекрасно, но это ведь не гуд! Вопрос - как в этом случае динамически объявить массив указателей
1 | Автор: aues | 2012-03-31, 11:21 | Изменено: aues - Сб, 2012-03-31, 11:21   |  Репутация: [ + 0 ]
Форум ПРОГРАММИСТОВ » ПРОГРАММИРОВАНИЕ » С, C++ » Нужна помощь - динамический массив (срочно)
  • Страница 1 из 1
  • 1
Поиск: