-1

Create a two dimensional dynamic integer array S. The size should be seq1_length+1 and seq2_length+1. If seq1_length = 10 and seq2_length = 10answer should beS[11][11]`. I used this code

S= new int *[len1];
for(int i=0;i<len1;i++)
S[i]=new int[len2];

How can I check the size of this array supposed to be S[11][11].

NathanOliver
  • 171,901
  • 28
  • 288
  • 402
Ibrahim
  • 9
  • 5

1 Answers1

0

First, you will get compile error "S does not name a type". Correct declaration should be

int* S = new int*[len1+1];
for (int i = 0; i < len1+1; i++)
{
    S[i] = new int[len2+1];
}

Len1+1 and Len2+1, because you need to have size one greater than seq1_length and seq2_length. For checking size you can simply do this

int count = 0;
for (int i = o; i < len1+1; i++)
{
    for (int j = o; j < len2+1; j++)
    {
        count++;
    }
}

std::cout << count << endl;
Nomi
  • 1
  • 1