Some tips
Converting the character string into digital approach
code show as below
Suma=0;
for (i = 0; i < strlen(a); i++) {
if (a[i] >= '0' && a[i] <= '9')
suma = suma * 10 + (a[i] - '0');
}
Do not question the last line of a space
I have always been to write a previously else if
Now learned, it can output a space on the front.
Here is a chestnut
for (int i = 0; i < 54; i++) {
if (i != 0) printf(" ");
//通过关系,使用一个表达式就搞定了输出问题
printf("%c%d", mp[a[i] / 13], a[i] % 13 + 1);
}
One problem C ++ getline (cin, str) encountered
① read principle getline (cin, str) that will be '\ n' character to end the complete line read, '\ n' carriage return, so when before reading a string with cin, you would enter a string, and then return, then getline (cin, str) read into the carriage when the gradation, and determines the end.
② The solution is to add a function cin.ignore in front of getline () will ignore the carriage return