블록 전환 암호 프로그램을 만들기위한 지정이 있습니다. 사용자는 자신이 선택한 문구를 입력해야하며, 프로그램은 공백, 문장 부호를 제거하고 소문자로 만들고 길이를 읽은 다음 모든 문자에 맞게 가장 가까운 사각형의 크기를 2 차원 배열로 만듭니다. 돌연변이 된 문자열에있는 문자와 나머지 문자를 임의의 문자로 채 웁니다.C++ 사용자 입력 문자열 길이를 기반으로 2 차원 배열 만들기
문제는 그 사각형을 만드는 데 문제가 있습니다.
나는이 지금까지 가지고int main()
{
string input;
cout << "Please enter message to cipher." << endl;
getline(cin, input);
/* do punctuation removal/mutation */
int strLength = input.length(); //after mutation
/* need to find the square here before applying sizes and values to arrays */
char * original = new char[][]; // sizes pending
char * transposed = new char[][]; // sizes pending
for (int i = 0; i <= /* size pending */ ; i++)
{
for (int j = 0; j <= /* size pending */ ; j++)
{
transposed[j][i] = original[i][j];
}
}
/* do more stuff here */
}
어떤 아이디어?
'char ** original'이 아니겠습니까? – irrelephant