- 1

I need help solving this question in c++

An n*n matrix can be represented using 1-D array of size n(n+1)/2 by sorting either the lower or upper triangle of the matrix . The elements that are not explicitly stored may be computed from those that are stored . How do we compute this ?

25th Sep 2020, 4:58 PM
Abdulrahim Alkhatib
Abdulrahim Alkhatib - avatar
4 Réponses
+ 1
Please show us your try, or it will seem as though this is your homework assignment that you want answers to, and not how to improve you try.
27th Sep 2020, 1:37 AM
Query
Query - avatar
+ 1
actually I tried two times
29th Sep 2020, 8:56 AM
Abdulrahim Alkhatib
Abdulrahim Alkhatib - avatar
+ 1
#include<iostream> using namespace std; int main() { int r1,r2,r3; int m=[r1;r2;r3]; r1=[1,2,3,4]; r2=[5,6,7,8]; r3=[4,3,2,1]; cout<<"Enter the elements of 3X3 matrix: "<<endl; for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { cin>>m[i][j]; } } cout<<endl; for(int row=0;row<3;row++) { for(int col=0;col<3;col++) { if(row<col) { cout<<m[row][col]<<" "; } } cout<<endl; } return 0; }
29th Sep 2020, 8:58 AM
Abdulrahim Alkhatib
Abdulrahim Alkhatib - avatar
+ 1
#include <iostream> using namespace std; int main() { //uppar 3X3 triangular matrix int a[6]; for(int i=0;i<6;++i){ cout<<"enter values"; if(i==4){ a[i]=0; } else { cin>>a[i]; } } for(int i=0;i<6;++i){ cout<<a[i]<<endl; } return 0; }
29th Sep 2020, 8:59 AM
Abdulrahim Alkhatib
Abdulrahim Alkhatib - avatar