[Java]
/*
* Start the program header annotation.
* Copyright and version Declaration of the program
* Copyright (c) 2011, a student from the computer College of Yantai University
* All rights reserved.
* File name: Output a diamond
* Author: Xue Guangchen
* Completion date: January 1, September 15, 2011
* Version No.: x1.0
* Description of tasks and Solutions
* Input description:
* Problem description: A diamond is output, and the number of rows is input by the user.
* Program output:
* End the comment in the program Header
*/
Package xue.com;
Public class Triangle4 {
/**
* @ Param args
*/
Public static void main (String [] args ){
// TODO Auto-generated method stub
System. out. println ("Enter the number of triangle rows :");
Int n = Console. readInt ();
For (int I = 0; I <n-1; I ++)
{
For (int x = I + 1; x <n; x ++)
{
System. out. print ("");
}
For (int y = 0; y <(I + 1) * 2-1; y ++)
{
System. out. print ("*");
}
System. out. println ();
}
For (int I = 0; I <n; I ++)
{
For (int x = 0; x <I; x ++)
{
System. out. print ("");
}
For (int y = I; y <2 * n-I-1; y ++)
{
System. out. print ("*");
}
System. out. println ();
}
}
}
Running result: