睡眠不足の可能性がありますこのC++ forループ、iside a forループについて説明してください。更新2
どのような順序で矩形が構築されるのですか?長さ最初に高さ?
そして示されただけcout<<
が"*"
であれば、なぜcin>>
値が出力に*
の量として使用されていますか?
は私が5歳だったようなので、それを説明してください、それはあなた方の多くはNoobのものを知っている:D
コードが英語この時点で、再び、編集されました。そのエラーを指していただき、ありがとうございます、より多くのコーヒーを必要とする:/
#include <iostream>
using namespace std;
void drawRectangle (int l, int h)
{
for (int line (0); line < h; line++)
{
for (int column (0); column < l; column++)
{
cout << "*";
}
cout<<endl;
}
}
int main()
{
int length, height;
cout << "Length for rectangle : ";
cin >> length;
cout << "Height for rectangle : ";
cin >> height;
drawRectangle (length, height);
return 0;
}
UPDATE 1:
コードが台無しにされた場合でも、答えたすべての人に感謝します。私はちょうど私が理解を確認する:
#include <iostream>
using namespace std;
void drawRectangle (int l, int h)
{
for (int line (0); line < h; line++) //this is the outer loop
{
for (int column (0); column < l; column++) //this is the inner loop
{
cout << "*";
}
cout<<endl; //the length is written then jumps here to break.
/*So, the outer loop writes the length,from left to right, jumps to the cout<<endl; for a line break, then the inner loop writes the height under each "*" that forms the length?/*
はUPDATE 2:右ここに私の答えを得た http://www.java-samples.com/showtutorial.php?tutorialid=326
私はこの謎が解決されると思います!私の質問に答えた皆さん、ありがとうございます:)私はあなたの助けに感謝します!
で
:出力に含まは次のようになります。 '。ブレースは間違った位置にありますか? –
*私は5歳のように説明してください*:母親のforループとお父さんのforループがお互いを大好きにすると、彼らは互いに入れ子になってコンパイルエラーを生成します:['Line 13:エラー: '}'トークンの前に期待されるprimary-expression](http://codepad.org/AvBcGf1o)あなたが年上であれば、コンパイルするコードを投稿する方法を学びます。 –
@ todda.speot.is:それはすごい説明だった。おそらく、彼は矢を膝にかけたでしょう。 – AusCBloke