lzth.net
当前位置:首页 >> jAvA二维数组打印矩阵 >>

jAvA二维数组打印矩阵

按照你的要求打印矩阵的Java程序如下public class A { public static void main(String[] args) { int N=3; int n,i,j; for(i=1;i<=N;i++){ n=1; for(j=1;j<i;j++){ System.out.print(n+++" "); } for(j=i;j<=2*N-1-i;j++){ System.out.print(n+" "); } for(j=2*N-1-i+1;j<=2*

import java.util.Scanner; public class Main1 { public static void main(String ars[]){ Scanner s=new Scanner(System.in); System.out.println("请输入数组行数和列数"); int x=s.nextInt(); int y=s.nextInt(); int [][]awarry=new int[x][y];//初始化数组

你把那个System.out.println(b); 改成System.out.print(b);就可以了

1. 根据输入值n初始化二维数组大小 new int[2n-1][2n-1]2. 设置所有值为13. 改变行=n的值4. 改变列=n的值5. 输出数组

public class t { public static void main(string[] args) { int i,j; int[][] a = {{1,1,1},{2,2,2},{3,3,3}}; int[][] b = new int[3][3]; system.out.print("初始矩阵:\n"); for(i=0;i for(j=0;j system.out.print(a[i][j]+" "); } system.out.print("\n"); } system.out.print("

int a [][]= new int [4][4]; for (int i = 0; i int k=0; for (int j = 0; j a[i][j]=k++; } } for (int i = 0; i int k=0; for (int j = 0; j System.out.print(a[i][j]+" -- "); } System.out.println(); }

System.out.print("3x3"); for(int i = 0; i<3; i++){ for(int j = 0; j<3; j++){ System.out.print("*"); } System.out.println(); } System.out.print("5x4"); for(int i = 0; i<4; i++){ for(int j = 0; j<5; j++){ System.out.print("*"); } System.out.println(); } System.out.

for(int i=0, i<3; i++) { for(int j=0; j<5; j++) { C[i][j]=0; for(int t=0, t<4; t++) C[i][j]+=A[i][t]*B[t][j]; } }

class matric{ public static void main(String args[]){ System.out.print("16 15 14 13\n5 4 3 12\n6 1 2 11\n7 8 9 10\n"); } }

for(int i=0;i for(int j=0;j if(i==0||j==0) { System.out.print(0+" "); continue; } if(i>j) { System.out.print(i+" "); } else { System.out.print(j+" "); } } System.out.println(); }

nnpc.net | lpfk.net | hbqpy.net | xmlt.net | whkt.net | 网站首页 | 网站地图
All rights reserved Powered by www.lzth.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com