[英]How can I make additions to this code to print a full triangle with my arduino?
它顯然只形成了半個三角形,但我不知道如何解決這個問題。 我是新手,老實說,我真的不知道如何使用它,因此非常感謝您的幫助。 我走了這么遠,但現在我迷路了:
void setup()
{
Serial.begin(9600);
Serial.setTimeout(100000); // timeout now is 100 seconds
// read a number from serial port
String s = Serial.readStringUntil(10); // read a line from serial port
int n = s.toInt(); // convert the input string to integer value
for (int i=0; i<n; i++){
for (int j=0; j<i+1; j++){
Serial.print("*" );
}
Serial.print("\n");
}
}
void loop(){
}
用行替換 n
for(int i = 1, k = 0; i <= rows; ++i, k = 0)
{
for(space = 1; space <= rows-i; ++space)
{
cout <<" ";
}
while(k != 2*i-1)
{
cout << "* ";
++k;
}
cout << endl;
}
這里的輸出
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.