だから私は別の問題に直面しています。私は運がないので、これを約1時間修正しようとしています。このネストされた while ループを機能させることができません。コードは入力に従って行を挿入する必要がありますが、現在は永遠に続いています。
#include <iostream>
using namespace std;
void PrintLines(char characterValue, int characterCount, int lineCount);
// I'm going to have to change char characterValue to int characterValue
// will this still work if they are in seperate files?
void PrintLines(char characterValue, int characterCount, int lineCount)
{
while (lineCount--) //This is the problem
{
while (characterCount--)
{
cout << characterValue;
}
cout << "\n";
}
}
int main()
{
char Letter;
int Times;
int Lines;
cout << "Enter a capital letter: ";
cin >> Letter;
cout << "\nEnter the number of times the letter should be repeated: ";
cin >> Times;
cout << "\nEnter the number of Lines: ";
cin >> Lines;
PrintLines(Letter, Times, Lines);
return 0;
これを行うと、正しく機能するかどうかを確認します。私はそれが...
while (lineCount--) //This is to check
cout << "\n%%%";
{
while (characterCount--)
{
cout << characterValue;
}
}
:( Lines = 4 and Times = 3 and Letter = A の場合)
%%%
%%%
%%%
%%%AAA