我是C++中的新手。我想在C++中繪製一個字符V如何繪製V字母形狀在C++中使用星號(*)
我只是做了這個。我不知道如何進一步得到所需的結果。
#include <iostream.h>
using namespace std;
int main()
{
int i, j;
for()
{
for()
{
if(i == j)
{
cout << "*";
}
else
{
cout << " ";
}
}
cout<< endl;
return 0;
}
這段代碼甚至不應該編譯 - 你的外部for循環沒有右括號,for循環也沒有body(至少需要';;'是必需的) –
我知道。 我只是寫它作爲示例。 –
不要放棄!你超過了一半。如果你正確地寫了'for'頭文件(例如:'for(int i = 0; i <= height; ++ i)'),你會畫出V的左邊。在手邊,你需要爲if語句添加一個或者一個條件(比如'if(i == j ||/* some some maths here/* == j)')。 – Johnsyweb