123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- /**
- * <https://y.st./>
- * Copyright © 2017 Alex Yst <mailto:copyright@y.st>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org./licenses/>.
- **/
- $xhtml = array(
- 'title' => '<code>Unit7.java</code>',
- 'subtitle' => 'Written in <span title="Programming 1">CS 1102</span> of <a href="http://www.uopeople.edu/">University of the People</a>, finalised on 2017-05-24',
- 'copyright year' => '2017',
- 'body' => <<<END
- <blockquote>
- <pre><code>/*
- * Copyright (C) 2017 Alex Yst
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- package unit7;
- /**
- * Alex Yst's CS 1102 (Programming 1) Unit 7 submission
- *
- * This class was programmed to fill the requirements on the Unit 7 programming
- * assignment in University of the People's CS 1102 (Programming 1) course.
- *
- * @author Alex Yst
- */
- public class Unit7 {
- /**
- * This method takes a hard-coded matrix, performs some checks on it, and
- * computes the value of the matrix. Were the matrix not hard-coded, it would
- * work on any matrix, as the rest of the code is flexible.
- *
- * @param arguments Not implemented
- */
- public static void main(String[] arguments) {
- int[][] m = {
- {10, 12, 11},
- { 9, 8, 31},
- { 2, 16, 24},
- };
- int numberOfRows = m.length;
- int numberOfColumns = 0;
- if(numberOfRows != 0) {
- for(int[] row: m) {
- numberOfColumns = row.length;
- if(numberOfColumns != numberOfRows) {
- System.out.println("This is not a square matrix.");
- return;
- }
- }
- }
- int total = 0;
- for(int i = 0;i < numberOfColumns; i++) {
- total += m[i][numberOfColumns-1-i];
- }
- System.out.println("Value of secondary diagonal: " + total);
- }
- }</code></pre>
- </blockquote>
- END
- );
|