当前位置:网站首页>4.打印表格
4.打印表格
2022-04-22 05:34:00 【linsa_pursuer】
打印一个n×m的表格我们定义单位长度(水平方向有三个“-”,竖直方向有一个“|”,“|”对齐“+”)的巨型表格
输入只有一行包含两个整数n和m(0<n,m<13);输出n×m的表格
package com;
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner s = new Scanner(System.in);
print(s.nextInt(),s.nextInt());
}
public static void print(int a,int b){
for(int i=1; i<=a; i++){
String lineOne = "+";
String lineTwo = "|";
for(int j=1; j<=b; j++){
lineOne += "---+";
lineTwo += " |";
}
if(i==1){
System.out.println(lineOne);
}
System.out.println(lineTwo);
System.out.println(lineOne);
}
}
}
如:
输入:1 2
输出:
+---+---+
| | |
+---+---+
版权声明
本文为[linsa_pursuer]所创,转载请带上原文链接,感谢
https://blog.csdn.net/linsa_pursuer/article/details/120983495
边栏推荐
- Implementation of unity simple event system
- 二叉树五个重要性质(附图理解)
- 【FedMD,一种利用模型蒸馏的异构FL训练方法】FedMD: Heterogenous Federated Learning via Model Distillation
- Arrays常用方法(超详解)
- mysql表删除重复值,只保留一个
- 环形链表2
- 2022.4.21-----leetcode.824
- C language version: the pre order, middle order and post order non recursive traversal of binary tree
- 随机字符串工具类RandomStringUtils详解
- Unity creates dynamic classes through reflection
猜你喜欢

Integer source code

DolphinDB VSCode 插件使用教程

Idea 2021.1 Useful settings

判断链表是否有环

AssetBundle packaging based on unitygameframework framework

Realization of mathematical function curve editor with minscript script language

力扣19. 删除链表的倒数第 N 个结点

Application and selection of it power distribution and fire current limiting protector

Sourcetree version backtracking and single change version backtracking

Fundamentals of graphics - depth of field / DOF
随机推荐
C language version: traversal mode and reverse order of binary tree
Multithreaded rendering mechanism of Unreal Engine
List中set方法和add方法的区别
Redis实时同步工具推荐
GBase 8s V8. 8 SQL Guide: Tutorial - 6.1.1 (4)
Pratique du langage C (2) - - mise en oeuvre de l'addition polynomiale par liste liée
程序的编译(预处理操作)+ 链接
力扣876. 链表的中间结点
MySQL函数及练习题(二)
GBase 8s V8.8 SQL 指南:教程-5.2(3)
GBase 8s V8.8 SQL 指南:教程-6.1
GBase 8s V8.8 SQL 指南:教程-6.1.2(1)
Fundamentals of graphics - flood
MySQL 第6章 Navicat 的安装与使用
Establishment, addition, deletion, modification and query of sequence table
Hloj 1936 covered with squares
Simulate the infectious disease model with MATLAB (only do matlab simulation learning and practice, not actual situation and application)
2022.4.21-----leetcode. eight hundred and twenty-four
Codeforces Round #784 (Div. 4) All Problems
C language version: establishment and basic operation of chain team