herrDeng網內搜尋

自訂搜尋

Ads

2014年5月6日 星期二

Java作業9陣列
















用亂數產生一值為01的7x8之2D陣列
計算[3][4]周邊8個變數值的總和

33 則留言:

B10233072黃君寰 提到...

package zz;

import java.util.Random;

public class jj {

public static void main(String[] args) {
Random rnd=new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0; j<a[i].length; j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if (a[i][j]==1) count++;
}
System.out.println();
}
System.out.println(count+"顆地雷!");

}

}

B10233066張哲毓 提到...

package aaa;

import java.util.Random;

public class bb {

public static void main(String[] args) {
Random rnd=new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0; j<a[i].length; j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if (a[i][j]==1) count++;
}
System.out.println();
}
System.out.println(count+"顆地雷!");

}

}

b10233080陳芊慈 提到...

import java.util.Random;

public class zzz {

public static void main(String[] args) {
Random rnd=new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0; j<a[i].length; j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if (a[i][j]==1) count++;
}
System.out.println();
}
System.out.println(count+"顆地雷!");
}
}

B10233061吳興強 提到...

import java.util.Random;
public class ex1 {

public static void main(String[] args) {
Random rnd=new Random();
int[][] a=new int[7][8];
int count=0;
for (int i=0;i<a.length;i++){
for(int j=0;j<a[i].length; j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if (a[i][j]==1) count++;
}
System.out.println();
}
System.out.println(count+"顆地雷!");
int sum=0;
for (int x=2;x<=4;x++){
for (int z=3;z<=5;z++){
sum+=a[x][z];
}
}
System.out.print(sum-(a[3][4]));
}
}

B10233082 唐偉強 提到...

package asas;
import java.util.Random;
public class xcxcxc {

public static void main(String[] args) {
Random rnd=new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0;j<a.length;j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if(a[i][j]==1) count++;

}
System.out.println();
}

System.out.println(count+"顆地雷");
System.out.print((a[2][3]+a[3][3]+a[4][3]+a[2][4]+a[3][5]+a[2][5]+a[3][5]+a[4][5]));
}

}

B10233095李元宏 提到...

package asas;
import java.util.Random;
public class xcxcxc {

public static void main(String[] args) {
Random rnd=new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0;j<a.length;j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if(a[i][j]==1) count++;

}
System.out.println();
}

System.out.println(count+"顆地雷");
System.out.print("[3][4]周邊8個變數值的總和="+(a[2][3]+a[3][3]+a[4][3]+a[2][4]+a[3][5]+a[2][5]+a[3][5]+a[4][5]));
}

B10233064莊英霆 提到...

import java.util.Random;
public class ting {
public static void main(String[] args) {

Random rnd=new Random();
int[][] a=new int [7][8];
int count=0;
for(int i=0;i<a.length;i++){
for(int j=0;j<a[i].length;j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if(a[i][j]==1) count++;
}
System.out.println();
}
System.out.println(count+"顆地雷!");
int sum=0;
for(int x=2;x<=4;x++){
for(int z=3;z<=5;z++){
sum+=a[x][z];
}
}
System.out.print(sum-(a[3][4]));
}
}

B10233087黃少洋 提到...

package fdgdgds;
import java.util.Random;
public class EFDSF {

public static void main(String[] args) {
Random rnd=new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0;j<a.length;j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if(a[i][j]==1) count++;

}
System.out.println();
}

System.out.println(count+"顆地雷");
System.out.print((a[2][3]+a[3][3]+a[4][3]+a[2][4]+a[3][5]+a[2][5]+a[3][5]+a[4][5]));
}

}

B10233073 楊博宇 提到...

package roger;
import java.util.Random;
public class roger123 {

public static void main(String[] args) {
Random rnd=new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0;j<a.length;j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if(a[i][j]==1) count++;

}
System.out.println();
}

System.out.println(count+"顆地雷");
System.out.print((a[2][3]+a[3][3]+a[4][3]+a[2][4]+a[3][5]+a[2][5]+a[3][5]+a[4][5]));
}

}

Y10211064黃耀葦 提到...

package AWEFF;
import java.util.Random;
public class AAA {

public static void main(String[] args) {
Random rnd=new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0;j<a.length;j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if(a[i][j]==1) count++;

}
System.out.println();
}

System.out.println(count+"顆地雷");
System.out.print((a[2][3]+a[3][3]+a[4][3]+a[2][4]+a[3][5]+a[2][5]+a[3][5]+a[4][5]));
}

}

B10233062 黃聖評 提到...

package she;
import java.util.*;
public class she1 {

public static void main(String[] args) {
Random rnd=new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0;j<a.length;j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if(a[i][j]==1) count++;

}
System.out.println();
}

System.out.println(count+"顆地雷");
System.out.print((a[2][3]+a[3][3]+a[4][3]+a[2][4]+a[3][5]+a[2][5]+a[3][5]+a[4][5])-a[3][4]);

}

}

B10233098 陳孟緣 提到...

import java.util.Random;


public class AS {

public static void main(String[] args) {
Random rnd=new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0; j<a[i].length; j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if(a[i][j]==1) count++;
}
System.out.println();
}
System.out.println(count+"顆地雷!");
}
}

B10233097 邱宥甄 提到...

package aaaa;

import java.util.Random;

public class QQQQQQ {

public static void main(String[] args) {
Random rnd=new Random();
int [][] a=new int [7][8];
int count=0;
for (int i=0;i<a.length; i++){
for(int j=0;j<a[i].length;j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if (a[i][j]==1) count++;
}
System.out.println();
}
System.out.println(count+"顆地雷!");
}
}

B10233084 陳億如 提到...

package hello0506;
import java.util.Random;
public class Ex2 {
public static void main(String[] args) {
Random rnd= new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0; j<a[i].length; j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if (a[i][j]==1) count++;
}
System.out.println();
}
System.out.println(count+"顆地雷");
int sum=0;
for(int x=2;x<=4;x++){
for(int z=3;z<=5;z++){
sum+=a[x][z];
}
}
System.out.println(sum-(a[3][4]));
}
}

B10233069連于傑 提到...

package hello506;

import java.util.Random;

public class Ex2 {

public static void main(String[] args) {
Random rnd=new Random();
int[][] a= new int[7][8];
int count=0;
for (int i=0;i<a.length;i++){
for(int j=0;j<a[i].length;j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if (a[i][j]==1) count++;
}
System.out.println();
}
System.out.println(count+"顆地雷!");
System.out.print((a[2][3]+a[3][3]+a[4][3]+a[2][4]+a[3][5]+a[2][5]+a[3][5]+a[4][5]));

}

}

B10233075 提到...

package hello0506;
import java.util.Random;
public class hello1 {
public static void main(String[] args) {
Random rnd= new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0; j<a[i].length; j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if (a[i][j]==1) count++;
}
System.out.println();
}
System.out.println(count+"顆地雷");
int sum=0;
for(int x=2;x<=4;x++){
for(int z=3;z<=5;z++){
sum+=a[x][z];
}
}
System.out.println(sum-(a[3][4]));
}
}

B10233081 藍立凱 提到...

package hello0506;
import java.util.Random;
public class Ex2 {
public static void main(String[] args) {
Random rnd= new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0; j<a[i].length; j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if (a[i][j]==1) count++;
}
System.out.println();
}
System.out.println(count+"顆地雷");
int sum=0;
for(int x=2;x<=4;x++){
for(int z=3;z<=5;z++){
sum+=a[x][z];
}
}
System.out.println(sum-(a[3][4]));
}
}

B10233063 張宜禎 提到...

package hello0506;
import java.util.Random;
public class Ex2 {
public static void main(String[] args) {
Random rnd= new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0; j<a[i].length; j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if (a[i][j]==1) count++;
}
System.out.println();
}
System.out.println(count+"顆地雷");
int sum=0;
for(int x=2;x<=4;x++){
for(int z=3;z<=5;z++){
sum+=a[x][z];
}
}
System.out.println(sum-(a[3][4]));
}
}

B10233091許少威 提到...

package hello0506;
import java.util.Random;
public class Ex2 {
public static void main(String[] args) {
Random rnd= new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0; j<a[i].length; j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if (a[i][j]==1) count++;
}
System.out.println();
}
System.out.println(count+"顆地雷");
int sum=0;
for(int x=2;x<=4;x++){
for(int z=3;z<=5;z++){
sum+=a[x][z];
}
}
System.out.println(sum-(a[3][4]));
}
}

B10233076 提到...

package hello;
import java.util.Random;
public class ex2 {
public static void main(String[] args) {
Random rnd= new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0; j<a[i].length; j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if (a[i][j]==1) count++;
}
System.out.println();
}
System.out.println(count+"顆地雷");
int sum=0;
for(int x=2;x<=4;x++){
for(int z=3;z<=5;z++){
sum+=a[x][z];
}
}
System.out.println(sum-(a[3][4]));
}
}

b10233068邱佳函 提到...

package hello506;

import java.util.Random;

public class ex2 {

public static void main(String[] args) {
Random rnd=new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0; j<a[i].length; j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if (a[i][j]==1) count++;
}
System.out.println();
}
System.out.println(count+"顆地雷!");
count=0;
for(int i=2; i<=4; i++)
for(int j=3; j<=5; j++)
count+=a[i][j];
count-=a[3][4];
System.out.println(count);
}
}

b10233068邱佳函 提到...

package hello506;

import java.util.Random;

public class ex2 {

public static void main(String[] args) {
Random rnd=new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0; j<a[i].length; j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if (a[i][j]==1) count++;
}
System.out.println();
}
System.out.println(count+"顆地雷!");
count=0;
for(int i=2; i<=4; i++)
for(int j=3; j<=5; j++)
count+=a[i][j];
count-=a[3][4];
System.out.println(count);
}
}

B10233090 提到...

package dh;
import java.util.Random;

public class jjjj {

public static void main(String[] args) {

Random rnd=new Random();
int [][] a=new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0; j<a[i].length; j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]==1?"x":"o");
if (a[i][j]==1) count++;

}
System.out.println();

}
System.out.println(count+"顆地雷");
int sum=0;
for(int i=2;i<=4;i++){
for(int j=3;j<=5;j++){
count+=a[i][j];
count-=a[3][4];
System.out.println(count);
}
}
}

}

B10233110 提到...

package hhh;
import java.util.Random;

public class fff {

public static void main(String[] args) {

Random rnd=new Random();
int [][] a=new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0; j<a[i].length; j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]==1?"x":"o");
if (a[i][j]==1) count++;

}
System.out.println();

}
System.out.println(count+"顆地雷");
int sum=0;
for(int i=2;i<=4;i++){
for(int j=3;j<=5;j++){
count+=a[i][j];
count-=a[3][4];
System.out.println(count);
}
}
}

}

B10233089 提到...

import java.util.Random;
public class hello2 {
public static void main(String[] args) {
Random rnd=new Random();
int [ ][ ]a= new int [7][8];
int count=0;
for(int i=0;i<a.length;i++){
for(int j=0;j<a[i].length;j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if (a[i][j]==1) count++;
}
System.out.println();
}
System.out.println(count+"顆地雷!");
count=0;
for(int i=2; i<=4; i++)
for(int j=3; j<=5; j++)
count+=a[i][j];
count-=a[3][4];
System.out.println(count);

}
}

B10233071 提到...

package agg;
import java.util.Random;

public class hdhd {

public static void main(String[] args) {

Random rnd=new Random();
int [][] a=new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0; j<a[i].length; j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]==1?"x":"o");
if (a[i][j]==1) count++;

}
System.out.println();

}
System.out.println(count+"顆地雷");
int sum=0;
for(int i=2;i<=4;i++){
for(int j=3;j<=5;j++){
count+=a[i][j];
count-=a[3][4];
System.out.println(count);
}
}
}

}

B10233067 提到...

package ex0506;
import java.util.Random;
public class hello02 {
public static void main(String[] args) {
Random rnd=new Random();
int [][] a=new int[7][8];
int count=0;
for(int i=0;i<a.length;i++){
for(int j=0;j<a[i].length;j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if(a[i][j]==1)count++;
}
System.out.println();
}
System.out.println(count+"顆地雷!");
count=0;
for(int i=2;i<=4;i++)
for(int j=3;j<=5;j++)
count+=a[i][j];
count-=a[3][4];
System.out.println(count);
}
}

B10233102 提到...

package gg;
import java.util.Random;

public class jj {

public static void main(String[] args) {

Random rnd=new Random();
int [][] a=new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0; j<a[i].length; j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]==1?"x":"o");
if (a[i][j]==1) count++;

}
System.out.println();

}
System.out.println(count+"顆地雷");
int sum=0;
for(int i=2;i<=4;i++){
for(int j=3;j<=5;j++){
count+=a[i][j];
count-=a[3][4];
System.out.println(count);
}
}
}

}

B10233092 提到...

package aaaaaaa;
import java.util.Random;

public class hhhhhhhhh {

public static void main(String[] args) {

Random rnd=new Random();
int [][] a=new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0; j<a[i].length; j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]==1?"x":"o");
if (a[i][j]==1) count++;

}
System.out.println();

}
System.out.println(count+"顆地雷");
int sum=0;
for(int i=2;i<=4;i++){
for(int j=3;j<=5;j++){
count+=a[i][j];
count-=a[3][4];
System.out.println(count);
}
}
}

}

B10233065 提到...

package hello0506;

import java.util.Random;

public class hello {

public static void main(String[] args) {
Random rnd=new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0;j<a[i].length;j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if (a[i][j]==1) count++;
}
System.out.println();
}
System.out.println(count+"顆地雷!");
count=0;
for(int i=2; i<=4; i++)
for(int j=3; j<=5; j++)
count+=a[i][j];
count-=a[3][4];
System.out.println(count);
}

}

B10233096 提到...

package roger;
import java.util.Random;
public class roger123 {

public static void main(String[] args) {
Random rnd=new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0;j<a.length;j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if(a[i][j]==1) count++;

}
System.out.println();
}

System.out.println(count+"顆地雷");
System.out.print((a[2][3]+a[3][3]+a[4][3]+a[2][4]+a[3][5]+a[2][5]+a[3][5]+a[4][5]));
}

}

B10233073 楊博宇 提到...

package rgar;
import java.util.Random;
public class rgrgar {

public static void main(String[] args) {
Random rnd=new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0;j<a.length;j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if(a[i][j]==1) count++;

}
System.out.println();
}

System.out.println(count+"顆地雷");
System.out.print((a[2][3]+a[3][3]+a[4][3]+a[2][4]+a[3][5]+a[2][5]+a[3][5]+a[4][5]));
}

}

B10233074 許逸憲 提到...

package az;

import java.util.Random;

public class 123j {

public static void main(String[] args) {
Random rnd=new Random();
int [][] a= new int [7][8];
int count=0;
for(int i=0; i<a.length; i++){
for(int j=0; j<a[i].length; j++){
a[i][j]=rnd.nextInt(2);
System.out.print(a[i][j]);
if (a[i][j]==1) count++;
}
System.out.println();
}
System.out.println(count+"顆地雷!");

}

}

Related Posts Plugin for WordPress, Blogger...

熱門文章