I know the logic two get into a symmetric matrix the values of an array
int k=0;
for (int i = 0; i < size; i++){
for (int j = 0; j <= i; j++){
Q[i, j] = Q[j, i]= arr[k++];
}
}
But How to do this if I can only use a while loop?
I was doing something like:
int i=0;
int j=0;
while (reader.Read())
{
Q[i, j] = Q[j, i]=reader.GetDouble(1);
if (j < i){
j++;
}else{
j = 0;
i++;
}
}
Is the logic correct, How to improve this code?