import java.util.Scanner;

 public class Solution
 {
     public static void main(String[] args)
     {
         Scanner input = new Scanner(System.in);
         System.out.print("Enter the size for the matrix: ");
         int size = input.nextInt();

         input.close();

         int[][] array = new int[size][size];
         for(int i = 0; i < size; i++)
         {
             for(int j = 0; j < size; j++)
             {
                 array[i][j] = (int)(Math.random() * 2);
                 System.out.print(array[i][j] + " ");
             }
             System.out.println();
         }

         boolean judgement = true;
         int falseCount = 0;

         for(int i = 0; i < size; i++)
         {
             for(int j = 1; j < size; j++)
                 if(array[i][j] != array[i][j - 1])
                 {
                     judgement = false;
                     falseCount++;
                     break;
                 }
             if(judgement)
                 System.out.println("All " + array[i][0] + "s on row " + i);
             judgement = true;
         }
         if(falseCount == size)
             System.out.println("No same numbers on a row");

         judgement = true;
         falseCount = 0;
         for(int i = 0; i < size; i++)
         {
             for(int j = 1; j < size; j++)
                 if(array[j][i] != array[j - 1][i])
                 {
                     judgement = false;
                     falseCount++;
                     break;
                 }
             if(judgement)
                 System.out.println("All " + array[0][i] + "s on column " + i);
             judgement = true;
         }
         if(falseCount == size)
             System.out.println("No same numbers on a column");

         judgement = true;
         for(int i = 1; i < size; i++)
             if(array[i][i] != array[i - 1][i - 1])
             {
                 judgement = false;
                 break;
             }
         if(judgement)
             System.out.println("All " + array[0][0] + "s on the major diagonal");
         else
             System.out.println("No same numbers on the major diagonal");

         judgement = true;
         for(int i = size - 1; i > 0; i--)
             if(array[i][size - i - 1] != array[i - 1][size - i])
             {
                 judgement = false;
                 break;
             }
         if(judgement)
             System.out.println("All " + array[size - 1][0] + "s on the sub diagonal");
         else
             System.out.println("No same numbers on the sub diagonal");
     }
 }

HW7.14的更多相关文章

  1. Ubuntu 14.04中Elasticsearch集群配置

    Ubuntu 14.04中Elasticsearch集群配置 前言:本文可用于elasticsearch集群搭建参考.细分为elasticsearch.yml配置和系统配置 达到的目的:各台机器配置成 ...

  2. IIC驱动移植在linux3.14.78上的实现和在linux2.6.29上实现对比(deep dive)

    首先说明下为什么写这篇文章,网上有许多博客也是介绍I2C驱动在linux上移植的实现,但是笔者认为他们相当一部分没有分清所写的驱动时的驱动模型,是基于device tree, 还是基于传统的Platf ...

  3. Angular2 Hello World 之 2.0.0-beta.14

    公司现在采用angualrjs开发一些web应用,采用的是angular1,现在angular2已经差不多了,听说最近rc6已经出来了……其实感觉好慢啊!之前也做过一些anglar2的例子,但是没有记 ...

  4. 14门Linux课程,打通你Linux的任督二脉!

    Linux有很多优点:安全.自主.开源--,也正是这些优点使得很多人都在学Linux. 虽说网上有大把的Linux课程资源,但是对很多小白来说网上的课程资源比较零散并不适合新手学习. 正因为此,总结了 ...

  5. deepsooncms在Ubuntu 14.04上部署教程

    deepsooncms在Ubuntu 14.04上部署教程 一.安装mono1.在命令行运行sudo apt-key adv --keyserver keyserver.ubuntu.com --re ...

  6. ubuntu 14.10 lts 64-bits环境下使用Android Studio

    距离google发布android studio 1.0正式版已经两个月左右了.由于一直习惯使用eclipse+ADT的模式,而且曾在windows下试用一次Android Studio预览版,感觉卡 ...

  7. 在 Ubuntu 14.10 中借用 Windows 的字体

    在前一篇随笔中,我详细讨论了字体的分类及用途,也以 Fedora 20 为例,展示了字体配置的思路和方法.我在配置 Fedora 20 系统字体的时候,采用的是一种釜底抽薪的方法,完全抛开了系统原有的 ...

  8. 转-基于NodeJS的14款Web框架

    基于NodeJS的14款Web框架 2014-10-16 23:28 作者: NodeJSNet 来源: 本站 浏览: 1,399 次阅读 我要评论暂无评论 字号: 大 中 小 摘要: 在几年的时间里 ...

  9. CSharpGL(14)用geometry shader渲染模型的法线(normal)

    +BIT祝威+悄悄在此留下版了个权的信息说: CSharpGL(14)用geometry shader渲染模型的法线(normal) +BIT祝威+悄悄在此留下版了个权的信息说: 2016-08-13 ...

随机推荐

  1. GitHub的使用 —— 如何删除Repository

    如果要在GitHub上删除一个已经存在的Repository,该怎么办呢 ? 1.首先,点击这个资源(Repository),进入.会看到如下页面: 2.点击 Admin .在 Admin 页面的最下 ...

  2. python 中的集合(set) 详解

    在Python set是基本数据类型的一种集合类型,它有可变集合(set())和不可变集合(frozenset)两种. 创建集合set.集合set添加.集合删除.交集.并集.差集的操作都是非常实用的方 ...

  3. Introduction

    http://www.entityframeworktutorial.net/EntityFramework5/entity-framework5-introduction.aspx Basics o ...

  4. [HIHO1300]展胜地的鲤鱼旗(栈,dp)

    题目链接:http://hihocoder.com/problemset/problem/1300 给一个字符串,只包含'('和')',问存在多少个子串似的括号是匹配的. 匹配规则在题干中描(蒻)述( ...

  5. leetcode:String to Integer (atoi)

    Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. ...

  6. 【Todo】深入理解Java虚拟机 读书笔记

    有一个在线系列地址 <深入理解Java虚拟机:JVM高级特性与最佳实践(第2版)> http://book.2cto.com/201306/25426.html 已经下载了这本书(60多M ...

  7. BZOJ3028: 食物

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=3028 题解:列出母函数乘起来化简之后再展开,用插板法即可. 代码: #include<c ...

  8. HDU 5348 MZL's endless loop 给边定向(欧拉回路,最大流)

    题意: 给一个所有你可能想得到的奇葩无向图,要求给每条边定向,使得每个点的入度与出度之差不超过1.输出1表示定向往右,输出0表示定向往左. 思路: 网络流也是可以解决的!!应该挺简单理解的.但是由于复 ...

  9. SAS使用SPD引擎并报Encoding错误

     ERROR: Unable to open data file because its file encoding differs from the SAS session encoding and ...

  10. Android总结篇——Intent机制详解及示例总结

         最近在进行android开发过程中,在将 Intent传递给调用的组件并完成组件的调用时遇到点困难,并且之前对Intent的学习也是一知半解,最近特意为此拿出一些时间,对Intent部分进行 ...