Вы находитесь на странице: 1из 2

J0007

Laboratory Exercise

Matrices
Objectives:
At the end of the exercise, the students should be able to:

Use matrices in developing an application

Materials:

Computer with pre-installed Window 7 operating system and JDK


JCreator
Flash Drive

Procedures:
Using Matrices

1. Write a program that will read an n x n matrix into a two-dimensional array A and then,
determine which, if any, of the following special cases the matrix falls into:
Symmetric:

A[i][j] = A[j][i]

for all i and j

Diagonal:

A[i][j] = 0

whenever i and j are different

Upper Triangular:

A[i][j] = 0

whenever i < j

Lower Triangular:

A[i][j] = 0

whenever i > j

Symmetric sample
1
2
3
2
6
7
3
7
8
4
9
11
5
10
12

4
9
11
13
14

5
10
12
14
15

Diagonal sample
2
5
7
5
4
7
9
7
0
4
0
2
0
8
2

6
0
2
3
1

0
5
1
4
9

Upper Triangular sample


1
0
0
0
5
3
0
0
7
5
8
0
9
2
1
3
7
3
8
1

0
0
0
0
2

10 Laboratory Exercise 1

*Property of STI
Page 1 of 2

J0007

Lower Triangular sample


8
7
3
4
0
2
6
5
0
0
2
4
0
0
0
6
0
0
0
0

1
4
8
4
4

2. Make sure that all files are saved in your flash drive.

10 Laboratory Exercise 1

*Property of STI
Page 2 of 2

Вам также может понравиться