なぜうまくいかないのかわかりません。さらに、何がエラーなのかさえ言えません;/ 何がエラーなのか説明できますか?
コードは次のように想定されています: - お母さんのような単語で文字列を作成します。次に、2次元配列を作成して文字列で埋めます。空きスペースは _ で埋めます。だからお母さんボックス =
[m] [o]
[分] [_]
列から続くテキストで次の配列を埋めるようになりました。新しい配列に入力された mom_ は、mmo_ のようになります。次に、暗号化されたテキストを計算します。私がそこで何をしたか理解してくれることを願っています:D
ここにコードがあります
//wal = kolumny=wiersze
#include <cstdlib>
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
void pole(int &a,const int &l);
void tab(const char &s[],char &d[], char &f[],const int a);
int main(){
string code;
cin >> code;
int wall=1;
int d=code.length();
char tekst[d];
pole(wall,d);
strcpy(tekst,code);
char kw[wall][wall];
char szyfr[d];
tab(tekst,kw,szyfr,wall);
for (int i=0;i<d;i++)
cout << szyfr[i] << endl;
system("PAUSE");
return 0;
}
void pole(int &a,const int &l){
if (a*a < l)
pole(a+=1,l);
}
void tab(const char &s[],char &d[], char &f[],const int a){
int i=0;
for (int x=0;x<a;x++,i++){
for (int y=0;y<a;y++,i++){
if(s[i])
d[x][y]=s[i];
else d[x][y]=='_';
f[i]=d[x][y];
}
}
}