#include <stdio> // TODO: Not done. int main() { char[] l = "Aa0+/="; // Lookup table. int i = 0; // Index into lookup table. int c = 0; // Value of the current byte. int v = 0; // Value of the current cluster. int n = 0; // Number of bytes in the current cluster. // Get the new value. while (n < 3 && (c = getchar()) != EOF) { v = 256 * v + c; ++n; } if (c == EOF) break; i = v % 64; v /= 64; c = i % 26; i /= 26; if (i == 2) { i += c / 10; c = c % 10; } if (i == 3) { i += c; c = 0; } putchar(l[i] + c); }