Thread: Another program
-
December 7th, 2004, 11:21 AM #1
Another program
My C++ class this semester is almost over, and just to experiment with it, I made this program:
I call it 'encrypt', but it actually just raises the value of each letter in the string inputted, by 3. A becomes D, and so forth.Code:#include <iostream> #include <string> using namespace std; int a = 0; int b = 0; string inString; int choice; string encrypt(string & inString) { for(a = 0; a <= 3; a++) { inString[a] = inString[a] + 3; } return inString; } string decrypt(string & inString) { for(a = 0; a <= 3; a++) { inString[a] = inString[a] - 3; } return inString; } int main() { if(b == 0) { cout << "Would you like to:" << endl; cout << "1) Encrypt a string" << endl; cout << "2) Decrypt a string" << endl; cout << "3) Quit" << endl; "? "; cin >> choice; if(choice == 1) { cout << "Enter a string to be encrypted: "; cin >> inString; cout << "The encrypted string is: " << encrypt(inString) << endl; } else if(choice == 2) { cout << "Enter an encrypted string to decrypt: "; cin >> inString; cout << "The decrypted string is: " << decrypt(inString) << endl; } else if(choice == 3) { b == 1; } else { cout << "Invalid input, please try again." << endl; } } return 0; }
It doesn't stay open after selecting '1', or '2' when ran through windows, but the .EXE file is in here:
http://www.jonbuder.us/files/encrypt.rar
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
just made the switch
By Whitehawk in forum Graphics Cards and DisplaysReplies: 21Last Post: June 5th, 2004, 08:21 PM -
quick windowz taskbar question
By VHockey86 in forum Applications and Operating SystemsReplies: 11Last Post: December 7th, 2003, 06:15 PM -
Flash Help
By oolunchbox in forum Graphic Design and Digital PhotographyReplies: 4Last Post: November 20th, 2002, 12:55 PM -
Opera vs. IE?
By Xster in forum Applications and Operating SystemsReplies: 14Last Post: October 25th, 2002, 01:08 AM -
Windows XP Application Question...
By Martoch in forum Applications and Operating SystemsReplies: 6Last Post: June 12th, 2002, 01:32 PM



LinkBack URL
About LinkBacks





Reply With Quote

Well, I watched the first six episode of Shingeki no Kyoujin finally. It was more interesting than I expected, although had about the right level of whiny loser, strong females and overzealous idiots...
Thread About Anime