0% found this document useful (0 votes)
45 views4 pages

Fisa Info 2

The document contains 7 code snippets that initialize 2D arrays in C++ with different patterns based on the row and column indices. Each snippet takes in a number n, initializes a 2D array a of size n x n, and then prints out the values of a by looping through the rows and columns. The values assigned to each element of a depend on the relations between the row and column indices i and j.

Uploaded by

Mdc Imo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views4 pages

Fisa Info 2

The document contains 7 code snippets that initialize 2D arrays in C++ with different patterns based on the row and column indices. Each snippet takes in a number n, initializes a 2D array a of size n x n, and then prints out the values of a by looping through the rows and columns. The values assigned to each element of a depend on the relations between the row and column indices i and j.

Uploaded by

Mdc Imo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

3.

#include <iostream>

using namespace std;

int main()

int a[100][100],i,j,1<=n<=50;

cin>>n;

for(i=1;i<=n;i++)

for(j=1;j<=n;j++)

if(i>=j)

a[i][j]=0;

for(i=1;i<=n;i++)

{for(j=1;j<=n;j++)

cout<<a[i][j]}

cout<<"este triunghiulara superior";

else

cout<<"nu este triunghiulara superior";

return 0;

4.

#include <iostream>

using namespace std;

int main()

int a[100][100],i,j,0<=n<=23;

cin>>n;
for(i=1;i<=n;i++)

for(j=1;j<=n;j++)

if(i==j)

a[i][j]=x div 100;

if(i+j==n+1)

a[i][j]=(x div 10)% 10;

if(i!==j)&&((i+j)!==n+1)

a[i][j]==x%10;

for(i=1;i<=n;i++)

{ for(j=1;j<=n;j++)

cout<<a[i][j];

5.

#include <iostream>

using namespace std;

int main()

int a[100][100],i,j,3<=n<=50;

cin>>n;

for(i=1;i<=n;i++)

for(j=1;j<=n;j++)

if(i==j)

a[i][j]=x div 100;

if(i+j==n+1)

a[i][j]=x %10;

if(i!==j) && ((i+j)!==n+1)

a[i][j]= (x div 10) % 10;

for(i=1;i<=n;i++)

{for(j=1;j<=n;j++)
cout<<a[i][j];}

6.

#include <iostream>

using namespace std;

int main()

int a[100][100],2<=n<=15,i,j,p=0;

cin>>n>>p;

for(i=1;i<=n;i++)

for(j=1;j<=n;j++)

if(i==n)

a[i][j]=p+1;

if(i<=j)

a[i][j]=0;

if(i>=j)

a[i][j]=a[i][j+1]+a[i][j+2];

for(i=1;i<=n;i++)

{for(j=1;j<=n;j++)

cout<<a[i][j];

7.

#include <iostream>

using namespace std;

int main()

{
int a[100][100],i,j,2<n<50;

cin>>n;

for(i=1;i<=n;i++)

for(j=1;j<=n;j++)

if(i+j==n+1)

a[i][j]=0;

if(1<=i<=n) && (i+j<=n+1)

a[i][j]=i;

if(1<=i<=n) && (i+j>=n)

a[n-i+1][j]=i;

for(i=1;i<=n;i++)

{for(j=1;j<=n;j++)

cout<<a[i][j];

You might also like