Ok so what I'm trying to do is create a trans location cipher. For those among us that don't know alot about cryptography it is a method for jumbling up letters to disguise linguistic patterns(words) . What it does is takes a string as a parameter, determines length of string, tests if the length is a perfect square, if it is then it makes a 2-d array with its length and height equal to the lengths root. If it isn't then it cuts it down to size that is a perfect square. Then it does some other stuff that is irrelevant for my problem. If anyone wants a complete explanation of the source just let me know. When i try to compile these error statements come up.
1) at line 41- expected unqualified-id before "if"
2)at line 41- expected `,' or `;' before "if"
3)at line 44- expected unqualified-id before '||' token
4)at line 44- expected `,' or `;' before '||' token
5)at line 50- expected unqualified-id before "return"
6)at line 50- expected `,' or `;' before "return"
7)at line 51- expected declaration before '}' token
here is the source, please help.
1) at line 41- expected unqualified-id before "if"
2)at line 41- expected `,' or `;' before "if"
3)at line 44- expected unqualified-id before '||' token
4)at line 44- expected `,' or `;' before '||' token
5)at line 50- expected unqualified-id before "return"
6)at line 50- expected `,' or `;' before "return"
7)at line 51- expected declaration before '}' token
here is the source, please help.
Code:
#include <string>
#include <cstdlib>
using namespace std;
string tranString( string letters){
int length = letters.length();
int arrayLength;
int arrayHeight;
int extraLength = 0;
int column;
int subStr;
int row;
string beforeMix [arrayLength][arrayHeight];
for ( int n = 1; n < length; n++){
if( length % n == 0 && length / n == n){
arrayLength = length / n;
arrayHeight = arrayLength;
bool perSquare = 0;
n = length;
}
else if( (length - n) % n == 0 && (length - n) / n == n ){
arrayLength = length - n;
arrayHeight = length - n;
extraLength = n;
}
}
for (row = 0 ; row <= arrayHeight - 1; row++){
for ( column = 0, subStr = 0; column <= arrayLength - 1, subStr <= length - extraLength - 1; column++, subStr++){
beforeMix[column][row] = letters.substr(subStr, 1);
}
}
string newOrder = "";
for( column = arrayLength - 1, subStr = 0; column > -1, subStr <= (letters.length() - 1); column-- , subStr++)
for( row = arrayHeight - 1; row > -1; row--){
newOrder.substr( subStr, 1) = beforeMix[column][row];
}
}
if( newOrder.length() % 2 == 0;){
newOrder.insert( (newOrder.length() / 2), letters.substr( (length - extraLength) - 1, extraLength));
}
else
{
newOrder.insert( ((newOrder.length() - 1) / 2), letters.substr( (length - extraLength) - 1, extraLength));
}
return letters;
}
Comment