Page 2 of 2

Posted: Mon Jun 22, 2015 5:48 am
by manaregen
ABCDEFGHIJKLMNOPQRSTUVWXYZ

RSTUVWXYZABCDEFGHIJKLMNOPQ

C solution:

Code: Select all

#include <stdio.h>
#include <string.h>

int main() {
	char input[200] = "cqrb lryqna rb fjh, fjh qjamna cqjw axc cqracnnw. qnan, hxd wnena twxf qxf oja cx bqroc! xq kh cqn fjh, cqn jwbfna rb mnjmvjwblqnbc.";
	int i, len;

	len = strlen(input);
	for (i=0; i<len; i++) {
		if (input[i] == 0x20 || input[i] == 0x21 || input[i] == 0x2c || input[i] == 0x2e) continue;
		else if (input[i] <= 'i') input[i] += 17;
		else input[i] -= 9;
	}
	printf("%s\n", input);
	return 0;
}

Posted: Wed Jun 24, 2015 6:19 pm
by AMindForeverVoyaging
manaregen wrote: C solution
Yay, another person who codes in C! :D

Posted: Sun Apr 17, 2016 9:18 pm
by draw_in_dust
Another in C:

#include <stdio.h>
#include <string.h>

Code: Select all

int main(void){
    char x[132] = "cqrb lryqna rb fjh, fjh qjamna cqjw axc cqracnnw. qnan, hxd wnena twxf qxf oja cx bqroc! xq kh cqn fjh, cqn jwbfna rb mnjmvjwblqnbc";
    
    for (int i=0, n=strlen(x); i<n; i++){
        if (x[i]!=' ' && x[i]!= ',' && x[i]!='.' && x[i]!='!'){
            x[i] = (((x[i] - 97) + 17) % 26) + 97;
        }
        printf("%c", x[i]);
    }
    printf("\n");
}