0
我想建立左半金字塔如何建立半左上角金字塔在C
##
###
####
#####
######
#######
########
#########
这里是我的代码:
#include <stdio.h>
#include <cs50.h>
int main(void)
{
printf("Enter the height of the pyramid:");
unsigned int height = GetInt();
int counter;
while(height <1 || height >23){
printf("Incorect number,try again:");
height = GetInt();
}
for(counter = 2;counter <=height+1;++counter) {
printf("%.*s\n", counter, "##############################");
}
}
我建金字塔,而是离开角落我得到了右角金字塔。 我怎样才能把它转到左边?
P.S我知道,在这种情况下使用printf并不是最好的主意,但它告诉我用这个命令创建代码。
'的printf( “%* * S \ n”,身高+ 1,计数器,...' – BLUEPIXY
@BLUEPIXY谢谢,但是,你能解释一下这个coude做什么,我的意思是每个输入(特别是第一个输入) –
参见[printf](http://en.cppreference.com/w/c/io/fprintf ) – BLUEPIXY