Untitled

 avatar
user_0781376
plain_text
11 days ago
866 B
17
Indexable

public class Main {
    private static final int NUM_PAGES = 5;

    public static void countPagesAndHyperlinks(int[][] adjMatrix) {
        int numPages = NUM_PAGES;
        int numHyperlinks = 0;

        for (int i = 0; i < numPages; i++) //0 to 4
        {
            for (int j = 0; j < numPages; j++)  //0 to 5
            {
                numHyperlinks += adjMatrix[i][j];
            }
        }

        System.out.println("Number of web pages: " + numPages);
        System.out.println("Number of hyperlinks: " + numHyperlinks);
    }

    public static void main(String[] args) {
        int[][] adjMatrix = {
            {0, 1, 1, 0, 0},
            {0, 0, 1, 0, 0},
            {1, 0, 0, 0, 0},
            {0, 0, 1, 1, 0},
            {0, 0, 0, 0, 0}
        };

        countPagesAndHyperlinks(adjMatrix);
    }
}
Editor is loading...
Leave a Comment