#include #include #include #include using namespace std; int main(int argc, char** argv) { int offset = 0; int convert; char* offsetfile; char source; const int lettercount = 26; string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"; if (argc > 3) { cerr << "Invalid arguments.\n"; return 1; } // if (strcmp("-k", argv[1]) == 0) // offset = atoi(argv[2]); // else if (strcmp("-K", argv[1]) == 0) // offsetfile = argv[2]; // else // { // cout << argv[1] << endl; // cerr << "Wrong format for offset.\n"; // return 1; // } offset = atoi(argv[1]); if(offset < 0 || offset >= 26) {offset = 0; } offset = offset % lettercount; while(cin.get(source)) { source = toupper(source); int val = int (source); if ((val > 64) && (val < 91)) { convert = val - 65; cout << alphabet[(convert + offset)]; } } return 0; }