黑马程序员技术交流社区

标题: 99乘法表 [打印本页]

作者: ℃葫芦    时间: 2015-8-16 20:00
标题: 99乘法表
  1. class ForFor99
  2. {
  3.         public static void main(String[] args)
  4.         {

  5.                 /*
  6.                 九九乘法表
  7.                 1*1=1
  8.                 1*2=2 2*2=4
  9.                 1*3=3 2*3=6 3*3=9
  10.                
  11.                 */

  12.                 for (int x=1; x<=9 ;x++ )
  13.                 {
  14.                         for (int y=1; y<=x ;y++ )
  15.                         {
  16.                                 System.out.print(y+"*"+x+"="+y*x+"\t");
  17.                         }
  18.                         System.out.println();
  19.                 }


  20.                 /*
  21.                 \n:回车:
  22.                 \t:制表符。
  23.                 \b:退格。
  24.                 \r: 按下回车键。

  25.                 windows系统中回车符其实是由两个符号组成的 \r\n.
  26.                 linux中回车符是 \n.

  27.                        
  28.                 System.out.println("\\hello world\\");
  29.                 */
  30.        
  31.         }
  32. }
复制代码



作者: wzh4488    时间: 2015-8-16 21:03
感觉很基础的东西,不错哦!
作者: Coolman    时间: 2015-8-16 21:14
\r 叫回车 Carriage Return
\n 叫新行 New Line
但是都会造成换行

使用System.getProperty("line.separator")来获取当前OS的换行符
据我记得,各系统应当是
\r Mac
\n Unix/Linux
\r\n Windows
---------------
来自 CSDN 论坛




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2