bluesystem wrote:
讓我想到前兩天在跟以...(恕刪)
耶.....只用一個迴圈,有點難度耶.....

像這樣嗎?
// 1 *
// 2 **
// 3 ***
// 4 **
// 5 *
void StarTower(int count)
{
char* output_string = new char[count/2+1];
output_string[0] = '\0';
for ( int i=1; i<=count*2-1; i++)
{
if ( i <= count )
{
output_string[ i ] = output_string[i-1];
output_string[i-1] = '*';
}
else
{
output_string[ 2 * count - i] = '\0';
}
cout << output_string << endl;
}
delete [] output_string;
}
// 已修正斜體問題.....sorry.