473,395 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Encoder

58
I made this python script with another guy a year ago

Expand|Select|Wrap|Line Numbers
  1. ### This is a dictionary...
  2. MyDict={'a':'$','b':'i','c':'q','d':'s','e':'w','f':'~','g':'d','h':'2',
  3.         'i':'5','j':'6','k':'a','l':'g','m':'-','n':'j','o':'z','p':'%',
  4.         'q':'h','r':'9','s':'f','t':'7','u':'+','v':'c','w':'0','x':'8',
  5.         'y':'/','z':'x',' ':'*'}
  6.  
  7. ## This is just to show the mapping of the 'encoding'
  8. for k,v in MyDict.iteritems():
  9.     print k,' will be encoded to.. ',v
  10.  
  11. ## Here we ask for the word to be encoded
  12. ## Notice that i use the '.lower' method in case
  13. ##    the user inserts any uppercase letters
  14.  
  15. Word=raw_input("What is the word you want to encode?").lower()
  16.  
  17. ## This is an empty string to begin with
  18. Encoded_Word=''
  19.  
  20. ## Now we iterate over the inserted word to check each letter
  21. for letter in Word:
  22.     if MyDict.has_key(letter):
  23.         ## Insert to the string the coresponding character..
  24.         Encoded_Word=Encoded_Word+MyDict.get(letter)
  25.  
  26. ## Print the encoded word
  27. print Encoded_Word
  28.  
How do you make a dictionary in C++? And how do I make this script in the same format for a C++ program? I've tried in a very unethical and unlogical manner :P

Expand|Select|Wrap|Line Numbers
  1. //Encoder
  2.  
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8.  
  9. {
  10.  
  11.   int A1;  
  12.   int a;
  13.   int b;
  14.   int c;
  15.   int d;
  16.   int e;
  17.   int f;
  18.   int g;
  19.   int h;
  20.   int i;
  21.   int j;
  22.   int k;
  23.   int l;
  24.   int m;
  25.   int n;
  26.   int o;
  27.   int p;
  28.   int q;
  29.   int r;
  30.   int s;
  31.   int t;
  32.   int u;
  33.   int v;
  34.   int w;
  35.   int x;
  36.   int y;
  37.   int z;
  38.   int A3;
  39.  
  40.   system("cls");
  41.   cout << "--------------------------------------------------------------------------------";
  42.   cout << "Encoder";
  43.   cout << "\n--------------------------------------------------------------------------------";
  44.  
  45.   \u0020 = "*"
  46.   a = "$"
  47.   b = "i";
  48.   c = "q";
  49.   d = "s";
  50.   e = "w";
  51.   f = "~";
  52.   g = "d";
  53.   h = "2";
  54.   i = '5";
  55.   j = "6";
  56.   k = "a";
  57.   l = "g";
  58.   m = "-";
  59.   n = "j";
  60.   o = "z";
  61.   p = "%";
  62.   q = "h";
  63.   r = "9";
  64.   s = "f";
  65.   t = "7";
  66.   u = "+";
  67.   v = "c";
  68.   w = "0";
  69.   x = "8";
  70.   y = "/";
  71.   z = "x";
  72.  
  73.  
  74.   cout << "What is the word you want to encode?";
  75.   cin >> A1
  76.  
  77.   A3 = A1 +
  78.  
  79.   cout << A1;
  80.  
  81.   cout << "\n--------------------------------------------------------------------------------";
  82.   cout << "Bye";
  83.   cout << "\n--------------------------------------------------------------------------------";
  84.  
  85.   return 0;
  86.  
  87. }
  88.  
Mar 7 '08 #1
3 2334
sicarie
4,677 Expert Mod 4TB
While I would recommend using a data structure from the standard template library, I think the most equivalent structure would be a hash map.

However, depending on exactly what you are doing, that may not be the best choice for you. But it looks like the encoding is a static 1 to 1 replacement cypher, so it should work.
Mar 8 '08 #2
shing
58
While I would recommend using a data structure from the standard template library, I think the most equivalent structure would be a hash map.

However, depending on exactly what you are doing, that may not be the best choice for you. But it looks like the encoding is a static 1 to 1 replacement cypher, so it should work.
I don't quite understand the Standard template library. :(

This is what I have currently:

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2.  
  3. using namespace namespace_name std::map;
  4. {
  5.   int <key_type, data_type, [comparison_function]>;
  6.   int <string, char> encoder;
  7.  
  8. }
  9.  
  10. std::map <key_type, data_type, [comparison_function]>;
  11.  
  12. std::map <string, char> encoder;
  13.  
  14. encoder["a"] = '*',
  15. encoder["b"] = 'f';
  16. encoder["c"] = '[';
  17. encoder["d"] = 'p';
  18. encoder["e"] = ']';
  19. encoder["f"] = '\';
  20. encoder["g"] = 'm';
  21. encoder["h"] = 'z';
  22. encoder["i"] = 'n';
  23. encoder["j"] = '-';
  24. encoder["k"] = '_';
  25. encoder["l"] = ',';
  26. encoder["m"] = 'W';
  27. encoder["n"] = '`';
  28. encoder["o"] = '~';
  29. encoder["p"] = '&';
  30. encoder["q"] = 'i';
  31. encoder["r"] = 'x';
  32. encoder["s"] = '^';
  33. encoder["t"] = '+';
  34. encoder["u"] = 'j';
  35. encoder["v"] = 'q';
  36. encoder["w"] = '9';
  37. encoder["x"] = '4';
  38. encoder["y"] = '.';
  39. encoder["z"] = '=';
  40.  
  41. int main ()
  42.  
  43. {
  44.          int a;
  45.  
  46.          cout << "Encoded word?";
  47.          cin >> a;
  48.  
  49.          cout << "Encoded word is " << a;
  50.  
  51.          return 0;
  52.  
  53. }
  54.  
Mar 11 '08 #3
sicarie
4,677 Expert Mod 4TB
I don't quite understand the Standard template library. :(
Our resident oracle, weaknessforcats, just posted something that may help you in this thread.

Edit- This is assuming that you are understanding the language after your jump from Python. If you are looking for a more language-specific, C++ for programmer's type reference, post again and I'm sure we (by which I mean weaknessforcats as I have yet to see the limits of his knowledge) can come up with something.
Mar 11 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Paul Home | last post by:
Hi How come I always encountered this error after executing the following command ? C:\Inetpub\wwwroot\ASP>screnc admin.asp eadmin.asp Scripting encoder object ("Scripting.Encoder") failed on...
0
by: rockstar1971 | last post by:
Hello. I’m working with the Windows Media Encoder SDK to create an online jukebox for myself, but I’m having problems getting it to work. Here’s what I want to do: I’ve got a large...
3
by: Matt | last post by:
I'm trying to simply convert a .avi file recorded by our program to a wmv file, of course compressed as possible. I've looked at the examples provided by microsoft @...
0
by: Aaron Oxford | last post by:
Recently I tried installing the Windows Media Encoder SDK 9.5. Big mistake :-(, it's only got C++ support at this time and seems to have caused me a problem with my code, as well as refusing to...
0
by: Mamatha | last post by:
Hi I am developing small application in C#.NET,In that application when i click on one button,i want to display Windows Media Encoder Session Properties window. I searched in Google,and i got...
4
by: | last post by:
Hi all, we have a need to barcode encode and display a record identifier (number) both in html in the browser and through fdf in adobe acrobat in realtime. Is this possible? Can anyone make any...
0
by: Crisco www.misericordia.com.br | last post by:
Hi, friends! I am develop a simple encoder app, one form with one button that start the encoder. This is my code: ============================================================= Option...
0
by: Crisco www.misericordia.com.br | last post by:
Hi I m working on WEBRADIO Software. im using Windows media encoder 9 SDK on Windows 2003 server using VB.NET. My current scenario is my soundcard . My application will push my server the...
1
by: Geethu03 | last post by:
Hi I want to know the full details about the Query String encoder in PHP. How can i use the query string encoder in php.Please give the full details about the query string encoder. Thanks in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.