打印M的方法 java
来源:互联网 发布:古巴网络 编辑:程序博客网 时间:2024/05/18 01:00
package com.test;
public class printM {
public static void main(String[] args) {
test(4, 13);
}
public static void test(int xLength, int yLength) {
int arr[][] = new int[xLength][yLength];
boolean flag = true;
int j = xLength - 1;
int tool = -1;
for (int i = 0; i < yLength; i++) {
if (j == xLength - 1 && !flag) {
tool = -1;
flag = true;
}
if (j == 0 && flag) {
tool = 1;
flag = false;
}
arr[j][i] = i + 1;
j += tool;
}
for (int x = 0; x <= xLength - 1; x++) {
for (int y = 0; y < yLength; y++) {
if (arr[x][y] == 0) {
System.out.print(" ");
} else {
System.out.print(arr[x][y]);
}
}
System.out.println("");
}
}
}
public class printM {
public static void main(String[] args) {
test(4, 13);
}
public static void test(int xLength, int yLength) {
int arr[][] = new int[xLength][yLength];
boolean flag = true;
int j = xLength - 1;
int tool = -1;
for (int i = 0; i < yLength; i++) {
if (j == xLength - 1 && !flag) {
tool = -1;
flag = true;
}
if (j == 0 && flag) {
tool = 1;
flag = false;
}
arr[j][i] = i + 1;
j += tool;
}
for (int x = 0; x <= xLength - 1; x++) {
for (int y = 0; y < yLength; y++) {
if (arr[x][y] == 0) {
System.out.print(" ");
} else {
System.out.print(arr[x][y]);
}
}
System.out.println("");
}
}
}
0 0
- 打印M的方法 java
- 方法(打印m行n列)
- Java--平面图形M打印(通用版)
- 打印M
- 具体java打印方法的实现
- java 打印三角形,菱形的方法
- Java打印抛出异常的方法名称
- java中使用打印的方法
- JAVA打印倒金字塔的方法
- Java 打印堆栈的几种方法
- 用java实现打印日历的方法
- Java的打印对象和toString方法
- 去掉^M的方法
- 去除^M的方法
- 消除^M的方法
- JAVA 打印 M*N的螺旋矩阵(递归) 效率低得很
- 一道打印M型的面试题
- 一道关于打印M形状的问题
- 漫步IOS--Xcode修改字体、多工程创建和切换
- 同一客户端多个git账号的配置
- 75前面提到的nameNotFoundException的解决
- 最简单的基于librtmp的示例:发布(FLV通过RTMP发布)
- error C4996: 'fopen' 解决
- 打印M的方法 java
- Pascal's Triangle (Java)
- Ubuntu12.04 samba服务器搭建
- oracle数据库默认账号
- grep的用法
- cout格式控制
- android 自定义控件 使用declare-styleable进行配置属性(源码角度)
- Eclipse编辑器基本设置
- 240多个jQuery插件