вы хотите использовать cin.ignore () после своих операторов cin, потому что вы хотите игнорировать «\n» слева в буфере после принятия переменной int cin.
У меня есть аналогичная программа я использовал с аналогичной проблемой:
#include <iostream>
#include <iomanip>
#include <limits>
using namespace std;
int main() {
int i = 4;
double d = 4.0;
string s = "HackerRank ";
// Declare second integer, double, and String variables.
int n;
double d2;
string str;
// Read and save an integer, double, and String to your variables.
cin >> n;
cin >> d2;
cin.ignore();
getline(cin, str);
// Print the sum of both integer variables on a new line.
cout << i + n << endl;
// Print the sum of the double variables on a new line.
cout << d + d2 << endl;
// Concatenate and print the String variables on a new line
cout << s << str << endl;
// The 's' variable above should be printed first.
return 0;
}
Свойство границ является толщиной, точно так же, как поле и дополнение, таким образом, можно сделать Границу = "2,0,2,2" для получения границы 2 везде кроме вершины.