# hello world之等腰三角形命题

Hello World 中文意思是『你好,世界』。泛指在计算机屏幕上输出“Hello World”这行字符串的计算机程序。一般来说，这是每一种计算机编程语言中最基本、最简单的程序，亦通常是初学者所编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境，以及运行环境是否已经安装妥当。因为在Brian Kernighan 和Dennis M. Ritchie合著的《The C Programming Language》中使用它做为第一个演示程序，非常著名，所以后来的程序员在学习编程或进行设备调试时延续了这一习惯。

``````     *
***
*****
*******
*********
***********
``````

``````public class Main {
public static void main(String[] args) {
int n = 6;
for (int i = 1; i <= n; i++) {
for (int j = n - 1; j >= i; j--) {
System.out.print(" ");
}
for (int k = 1; k <= i; k++) {
System.out.print("*");
}
for (int h = 1; h < i; h++) {
System.out.print("*");
}
System.out.println();
}
}
}
``````

``````public class Main {
public static void main(String[] args) {
int n = 6;
for (int i = 1; i <= n; i++) {
for (int j = n - 1; j >= i; j--) {
System.out.print(" ");
}
for (int k = 1; k <= 2 * i - 1; k++) {
System.out.print("*");
}
System.out.println();
}
}
}
``````

``````#include<stdio.h>

int main() {
int n = 6;
for (int i = 0; i < n; i++) {
for (int j = n - 1; j > i; j--)
printf(" ");
for (int k = 0; k < 2 * i + 1; k++)
printf("*");
printf("\n");
}
return 0;
}
``````

``````var n = 6;
for (var i = 1; i <= n; i++) {
var str = "";
for (var j = n - 1; j >= i; j--) {
str += " ";
}
for (var j = 1; j <= 2 * i - 1; j++) {
str += "*";
}
console.log(str);
}
``````

MySQL闪亮登场，统统给我闪开：

``````DELIMITER \$\$

DROP PROCEDURE IF EXISTS `printStar`\$\$

CREATE PROCEDURE `printStar` (IN num INT)
BEGIN
DECLARE line INT DEFAULT num ;
DECLARE enter TEXT DEFAULT '\n' ;
DECLARE star TEXT DEFAULT '*' ;
DECLARE starTemp TEXT  DEFAULT '' ;
DECLARE blank TEXT DEFAULT ' ' ;
DECLARE i INT DEFAULT 0 ;
DECLARE j INT DEFAULT 0 ;
DECLARE k INT DEFAULT 0 ;
WHILE i < line DO
SET i = i + 1 ;
SET j = 0 ;
SET k = line - 1 ;
WHILE k >= i DO
SET k = k - 1 ;
SET starTemp = CONCAT(starTemp, blank) ;
END WHILE ;
WHILE j < 2 * i - 1 DO
SET j = j + 1 ;
SET starTemp = CONCAT(starTemp, star) ;
END WHILE ;
SET starTemp = CONCAT(starTemp, enter) ;
END WHILE ;
SELECT starTemp ;
END \$\$
DELIMITER ;

CALL printStar(6);
``````

SQLServer、Oracle等SQL家族还在场下蠢蠢欲动，没想到半路杀出个python，看到MySQL那冗长的存储过程，python3表示短小精悍才是硬道理：

``````n = 6
for i in range(1, n + 1):
for j in range(n - i):
print(' ', end='')
for k in range(2 * i - 1):
print('*', end='')
print()
``````

``````n = 6
for i in range(1, n + 1):
print(' ' * (n - i), '*' * (2 * i - 1))
``````

python默默的挥了挥衣袖，只留下众人痴呆的表情，胶水语言不发威还真以为我是hello world。。。