Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 decrypting ROT13 (vectors)
Index -> Programming, C++ -> C++ Help
Goto page Previous  1, 2, 3
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Geminias




PostPosted: Fri Jan 06, 2006 3:06 am   Post subject: (No subject)

i didn't realize you're rot13 function was intended to be a rot13 function. i thought you just dug something up as an example.

yes, it was entirely flawed here's a working source:

c++:

#include <iostream>
#include <vector>
#include <fstream>
#include <iterator>

using namespace std;

char rot13(char input);

int main()
{
   ifstream file("decrypt.txt");

   vector<char> transformed_chars;

   transform(istream_iterator<char>(file),
             istream_iterator<char>(),
             back_inserter(transformed_chars),
             rot13);

   copy(transformed_chars.begin(),
        transformed_chars.end(),
        ostream_iterator<char>(cout));

   return 0;
}

char rot13(char input)
{
   if (input <= 'm' || 'A' <= input && 'M' >= input )
   {
      return input + 13;
   }
   else if (input >= 'm' && input <= 'z')
   {
      return ((input % 77) + 64);
   }
   else if (input >= 'M' && input <= 'Z')
   {
      return ((input % 109) + 96);
   }
   else
   {
      return input;
   }
}

Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 3 of 3  [ 31 Posts ]
Goto page Previous  1, 2, 3
Jump to:   


Style:  
Search: