1006 - cypercode[i] = alpha2code( cypertext[i] ); c } pos =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<iostream> # using namespace std; u int key; int pos; char plaintext[80]; char plaincode[80]; char cypercode[80]; char cypertext[80]; c char alpha2code(char c){ if(c == '_') return 0; if(c == '.') return 27; return c-'a' + 1; } char code2alpha(char code){ if(code ==0) return '_'; if(code == 27) return '.'; return code -1 + 'a'; } int fun(){ int i; int t; for(i=0; cypertext[i] ; i++){
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cypercode[i] = alpha2code( cypertext[i] ); c } pos = i; for(i=0;i&lt;pos;i++){ plaincode[key * i % pos] = (cypercode[i] + i) % 28; } for(i=0; i&lt;pos;i++){ plaintext[i] = code2alpha( plaincode[i] ); } plaintext[pos] = 0; cout&lt;&lt;plaintext&lt;&lt;endl; } int main(){ cin&gt;&gt;key; while(key ){ cin&gt;&gt;cypertext; fun(); cin&gt;&gt;key; } return 0; }...
View Full Document

Ask a homework question - tutors are online