C++ bảng mã ASCII

Threads: C++

 Hướng dẫn học C++ từ Cơ bản đến nâng cao 

Write a program and a two functions (matching the prototypes provided) that allow you to encrypt and decrypt a user-entered string.


REQUIREMENTS
Your encrypt() function should be developed below main, and match the prototype provided:
     Accept an un-encrypted string as its only argument 
     Add a value of 3 to each ASCII character in the string argument string.
     Return the encrypted string

Your decrypt() function should be developed below main, and match the prototype provided:
     Accept an encrypted string string as its only argument (like from the encrypt() function)
     Subtract a value of 3 from each ASCII character in the string argument provided
     Return the decrypted string

Your main() should 
      prompt the user for a string
      call the encrypt() function and assign its return value to a string variable in main()
      print the encrypted string using the prompt provided
      pass the encrypted string to the decrypt() function
      store the return value from the decrypt() function in a string variable
      print the decrypted string using the prompt provided

OUTPUT
Example 1:
Enter a string to encrypt:  abc
Your encrypted string is: def
Your decrypted string is: abc

Example 2:
Enter a string to encrypt:  THIS is THE end
Your encrypted string is: WKLV#lv#WKH#hqg
Your decrypted string is: THIS is THE end

Please login or register to see more...

Tags: C++, OOP

Reviews

Please login or register to comment