int lineInputs = 0;
cin >> lineInputs;
int whatever = 0;
char* myArray = new char[arrayElements*lineInputs];
int j =0;
for(int i = 0; i < lineInputs; i++)
{
cin >> whatever;
for(j; j<total; j+=39)
{
for(int nom=0; j<arrayElements; nom++)
{
cin >> myArray[j];
}
}
}
在我的for循環的說,我有lineInputs = 4
和total = 156
for循環線陣列
含義4倍,我們做到這一點,我們要插入字符156到我的陣列。但是我們希望能夠讓每40個字符繼續進入陣列。
按照我們的要求,我們需要將這個輸入插入到數組中,但我覺得我的forloops已經搞亂了。 這將是輸入
4
1
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
2
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
3
HHTTTHHTTTHTHHTHHTTHTTTHHHTHTTHTTHTTTHTH
4
HTHTHHHTHHHTHTHHHHTTTHTTTTTHHTTTTHTHHHHT
這些40個字符的行的第一行4含義4。字符線上方的數字僅表示1 2 3 4等。
我該如何嘗試這個權利?
所以數組基本看起來像這樣。
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTHHTTTHHTTTHTHHTHHTTHTTTHHHTHTTHTTHTTTHTHHTHTHHHTHHHTHTHHHHTTTHTTTTTHHTTTTHTHHHHT
我建議停止混合C和C++:使用'std :: string'而不是'char *'。 (這不能解決你的問題,但它傷害了我的眼睛)順便說一下'arrayElements'是什麼?它沒有在任何地方指定。 – stefan