/* ========================================================================== */ /* */ /* Filename.c */ /* (c) 2001 Author */ /* */ /* Description */ /* */ /* ========================================================================== */ #include #include using namespace std; int main() { string cipher; int len; double ic; cin >> cipher; len = cipher.size(); return 0; } double index(string cipherText, int colSize, int offset){ //Convert string to array of chars char cipherArray[cipherText.size()]; strncpy(cipherArray, cipherText.c_str()); // initialize variables int len = 0; double ic = 0; int holding[26] = getFreq(colSize, offset, cipherArray); for (int i = 0; i < 26; i++){ ic = ic + holding[i]*(holding[i]-1); len = len + holding[i]; } return ic/(len*(len-1)); } static int[] getFreq( int keyLen, int offsetBy, char[] cipher){ int sums[26]; for (int i = offsetBy; i < sizeof(cipher); i+=keyLen){ sums[cipher[i]]++; } return sums; }