I am trying to write a program that calculates the score of 2 strings. One time without inserting spaces, and another with spaces. This part is straightforward. The scores are stored in a matrix, so I need to use a 2 dimensional vector, or a vector of a vector.
Scores are indexed by letters and based on these letters that I am going to get from the strings entered. For example:
score[b][u] = 12
score[k][p] = 3
score[r][ ] = 0
score[z][m] = -5
score[ ][s] = 1
I am stuck in two issues:
First one is using a char as a vector index.
Second is storing and comparing to calculate scores.
Thanks MiiniPaa,
I tried the snippet you posted. The program compiled with no errors, so I thought it was going to work, but when I run the program, I get this stupid error that the program stopped working. I think there is a runtime error.
vector<vector<int>> pam; Vector pam is empty, it does not have elements at all. So accessing vec['a'] is not going to work, as there is no element 48 ('a' code). You will need to allocate some elements to it (what I did in my snippet)
I did it this way at first but the code did not compile std::vector<std::vector<int>> pam (128, std::vector(128));
Missing template argument before ( token