[C++] Szyfr przestawieniowy
Ostatnio zmodyfikowano 2013-10-22 15:35
dami13 Temat założony przez niniejszego użytkownika |
[C++] Szyfr przestawieniowy » 2013-10-22 14:26:56 Witam. Znalazłem w internecie kod źródłowy do programu który mnie zainteresował. Niestety w czasie kompilacji dostaje informacje o błędach. Używam Codeblocks z kompilatorem MV C++ 2010 #include <iostream> #include <cmath> #include <string> using namespace std;
int main() { string text; int d, l, i, j; cout << "podaj tekst do zaszyfrowania "; getline( cin, text ); d = ceil( sqrt(( text.size() ) ); char tekst[ d ][ d ]; l = 0; for( i = 0; i < d; i++ ) { for( j = 0; j < d; j++ ) { if( l >= text.size() ) tekst[ i ][ j ] = '\0'; else tekst[ i ][ j ] = text[ l ]; l++; } } for( int i = 0; i < d; i++ ) { for( int j = 0; j < d; j++ ) { if( tekst[ j ][ i ] != '\0' ) cout << tekst[ j ][ i ]; } } }
Oraz informacje o błędach: main.cpp|14|error C2668: 'sqrt' : ambiguous call to overloaded function| main.cpp|14|error C2143: syntax error : missing ')' before ';'| main.cpp|15|error C2057: expected constant expression| main.cpp|15|error C2466: cannot allocate an array of constant size 0| main.cpp|15|error C2057: expected constant expression| main.cpp|15|error C2466: cannot allocate an array of constant size 0| main.cpp|15|error C2087: 'tekst' : missing subscript| main.cpp|15|error C2133: 'tekst' : unknown size| main.cpp|22|warning C4018: '>=' : signed/unsigned mismatch| ||=== Build finished: 8 errors, 1 warnings (0 minutes, 0 seconds) ===|
Ps. Odnośnik do strony z kodem. http://maturainformatyka.pl/algorytmy.php?url=szyfr-przestawieniowy. |
|
maly |
» 2013-10-22 15:35:45 sqrt przyjmuje double lub float podając inny typ kompilator niewie z który z nich wybrać i masz za dużo lub za mało nawiasów. |
|
« 1 » |