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. Solr相关概念详解:SolrRequestHandler

    转自:http://www.cnblogs.com/chenying99/archive/2012/07/24/2607339.html 1. standard (StandardRequestHan ...

  2. [每天一道A+B]签到检测程序

    签到检测程序,解析github提供的api内的json,解决了服务器和本地时间不同步的问题(时差+8H),实现按日期更新当前签到表.下一步是从api获取organization的信息,求出未签到的成员 ...

  3. Android项目真的要去做混淆(加密)处理

    以前做项目做是懒得混淆代码,因为要处理各种第三方的混淆东西,像友盟里面加了第三方库,又要特殊处理混淆操作,所以很麻烦,也懒得去做混淆操作,so 你懂的:但今天我用一个反编译工具,发现一个很可怕的事情 ...

  4. URAL1291. Gear-wheels

    1291 不知道为嘛被分在DP里了 瞎写 注意没被别的轮带动的情况 初始为0 分母为1 #include <iostream> #include<cstdio> #includ ...

  5. 浅谈B+树索引的分裂优化(转)

    http://www.tamabc.com/article/85038.html 从MySQL Bug#67718浅谈B+树索引的分裂优化   原文链接:http://hedengcheng.com/ ...

  6. Less tips:声明变量之前可以引用变量!

    Less中的variable可以在使用之后才被声明,这一特性对于希望覆盖前期声明的(比如bootstrap等第三方library的variable)变量,从而优雅地 使用你希望的效果提供了便利. 比如 ...

  7. Javascript零散知识点总结

    一.Javascript获取系统当前时间 <script type="text/javascript"> var time = new Date(); var date ...

  8. POJ 2069 Super Star

    模拟退火. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm& ...

  9. The Guide To Understanding mysqlreport

    The Guide To Understanding mysqlreport This guide to understanding mysqlreport explains everything t ...

  10. 解决VS2013/VS2010简体中文版无法使用ReSharper快捷键的问题

    对于简体中文版VS2013,若应用ReSharper快捷键失效,按下面方法修复: 1) 首先在ReSharper设置里,应用你的快捷键设置 2) 关闭VS2013,然后用记事本打开“%LOCALAPP ...