Как мне исправить эту ошибку?
#include<iostream> #include<string> #include<vector> using namespace std; const int CHARBOARDROWS = 7; const int CHARBOARDCOLS = 5; struct Input { string userInput; int x; int y; int choice; int timeStep; int speed; int length; }; Input info; void displayBoard(); Input inputProcess(); void displayA(vector<vector<char>> , int , int); void displayB(vector<vector<char>> , int , int); void displayC(vector<vector<char>> , int , int); void displayD(vector<vector<char>> , int , int); void displayE(vector<vector<char>> , int , int); void displayF(vector<vector<char>> , int , int); void displayG(vector<vector<char>> , int , int); void displayH(vector<vector<char>> , int , int); int main() { vector<vector<char>> letterA; letterA.resize(CHARBOARDROWS, vector<char>(CHARBOARDCOLS)); vector<vector<char>> letterB; letterB.resize(CHARBOARDROWS, vector<char>(CHARBOARDCOLS)); vector<vector<char>> letterC; letterC.resize(CHARBOARDROWS, vector<char>(CHARBOARDCOLS)); vector<vector<char>> letterD; letterD.resize(CHARBOARDROWS, vector<char>(CHARBOARDCOLS)); vector<vector<char>> letterE; letterE.resize(CHARBOARDROWS, vector<char>(CHARBOARDCOLS)); vector<vector<char>> letterF; letterF.resize(CHARBOARDROWS, vector<char>(CHARBOARDCOLS)); vector<vector<char>> letterG; letterG.resize(CHARBOARDROWS, vector<char>(CHARBOARDCOLS)); vector<vector<char>> letterH; letterH.resize(CHARBOARDROWS, vector<char>(CHARBOARDCOLS)); inputProcess(); // TODO : USE WHILE OR IF TO APPLY IN CHOICES displayBoard(); displayA(letterA,CHARBOARDROWS,CHARBOARDCOLS); return 0; } void displayBoard() { vector<vector<char>>A; int numOfRows = 20; int numOfCols = 40; //if (!((info.y)>numOfRows) || !((info.x)>numOfCols)) for (int i=0;i<info.length;i++) { if (info.userInput[i]=='A') { displayA(A,CHARBOARDROWS,CHARBOARDCOLS); } } for (int row=0;row<numOfRows;row++) { for (int column=0;column<numOfCols;column++) { cout<<'*'; } cout<<"\n"; } } Input inputProcess() { //Input info; cout<<"Please input a string (can up to 25 character long) :\n"; getline(cin,info.userInput); cout<<"\n*********************************************"; cout<<"\nAnchor dot is the top left dot of the string."; cout<<"\n*********************************************"; cout<<"\n\nPlease input coordinate x of anchor dot : \n"; cin>>info.x; cout<<"\nPlease input coordinate y of anchor dot :\n"; cin>>info.y; cout<<"\nPlease choose to display the string :"; cout<<"\n1-scrolling from left to right"; cout<<"\n2-scrolling from right to left"; cout<<"\n3-scrolling upwards"; cout<<"\n4-scrolling downwards"; cout<<"\n5-stationary without scrolling\n\n"<<"INPUT :"; cin>>info.choice; cout<<"\n*********************************************"; cout<<"\nOne time step is one refresh cycle which is\n" <<"made up of a screen clearing process and a\n" <<"display process."; cout<<"\n*********************************************"; cout<<"\n\nPlease input number of time steps :\n"; cin>>info.timeStep; cout<<"\nPlease input speed (between 1 to 10) :\n"; cout<<"1-the slowest\t 10-the fastest\n"; cin>>info.speed; info.length = info.userInput.length(); displayBoard(); } void displayA(vector<vector<char>> A, int row, int column) { A[0][2] = '#'; A[1][1] = '#'; A[1][3] = '#'; A[2][0] = '#'; A[2][4] = '#'; A[3][0] = '#'; A[3][4] = '#'; A[4][0] = '#'; A[4][1] = '#'; A[4][2] = '#'; A[4][3] = '#'; A[4][4] = '#'; A[5][0] = '#'; A[5][4] = '#'; A[6][0] = '#'; A[6][4] = '#'; for (auto val:A[0]) cout<<val[0][val]; } }
Что я уже пробовал:
1.Линии
cout<<val[0][val];показывает ошибку, что недопустимые типы [char][int] для индекса массива.Как исправить эту ошибку.
2. или если есть другой способ печати вектора, кроме метода, который я использовал.