#include <stdlib.h>
#include <stdio.h>
#include <string.h>
void caesar( const char *src, char *dst ) {
int i;
for( i = 0; src[i] != '\0'; ++i ) {
if( src[i] >= 'a' && src[i] <= 'z' ) {
dst[i] = 'a' + ( src[i]-'a' + i + 1 ) % 26;
}
else if( src[i] >= 'A' && src[i] <= 'Z' ) {
dst[i] = 'A' + ( src[i]-'A' + i + 1 ) % 26;
}
else {
}
}
dst[i]='\0';
}
void raseac( const char *src, char *dst ) {
int i;
dst[l] = '\0';
while(1) {
for( i = 0; i < l; ++i ) {
dst[i] = ( c < 26 )? ('a'+c): ('A'+c-26 );
}
caesar( dst, work );
if( strcmp( work
, src
) == 0 ) { return;
}
}
}
int main(){
char src[] = "text";
char encripted[sizeof(src)];
char decripted[sizeof(src)];
caesar( src, encripted );
raseac( encripted, decripted );
printf( "src=%s, encripted=%s, decripted=%s\n", src
, encripted
, decripted
); };
I2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHN0cmluZy5oPgoKdm9pZCBjYWVzYXIoIGNvbnN0IGNoYXIgKnNyYywgY2hhciAqZHN0ICkgewogIGludCBpOwogIGZvciggaSA9IDA7IHNyY1tpXSAhPSAnXDAnOyArK2kgKSB7CiAgICBpZiggc3JjW2ldID49ICdhJyAmJiBzcmNbaV0gPD0gJ3onICkgewogICAgICBkc3RbaV0gPSAnYScgKyAoIHNyY1tpXS0nYScgKyBpICsgMSApICUgMjY7CiAgICB9CiAgICBlbHNlIGlmKCBzcmNbaV0gPj0gJ0EnICYmIHNyY1tpXSA8PSAnWicgKSB7CiAgICAgIGRzdFtpXSA9ICdBJyArICggc3JjW2ldLSdBJyArIGkgKyAxICkgJSAyNjsKICAgIH0KICAgIGVsc2UgewogICAgICBmcHJpbnRmKCBzdGRlcnIsICJlcnJcbiIgKTsKICAgIH0KICB9CiAgZHN0W2ldPSdcMCc7Cn0KCnZvaWQgcmFzZWFjKCBjb25zdCBjaGFyICpzcmMsI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