943,589 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1392
  • C++ RSS
Jul 4th, 2009
0

substitution cipher help

Expand Post »
Been trying to make a substitution cipher decrypter, but it isn't working especially good. so I thought I might could get some help with it.

c++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2. #include <time.h>
  3. #include <windows.h>
  4. #include <iomanip.h>
  5. #include <string.h>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.  
  12.  
  13. bool EndThisShit(false);
  14. do {
  15. string input;
  16. cin >> input;
  17. int il;
  18. input.length() = il;
  19. int Ninput[il];
  20. Ninput[il] = input
  21. int y;
  22. for( y = 0; y < il; y++){
  23. int t =1;
  24. Ninput[fo] + t;
  25. i++;
  26. t++;
  27. }
  28. int a;
  29. for(a = 0; a < il; a++) {
  30. enum letter { a = 97, b, c, d, e, f, g, h, i, j, k, l, m, n, o , p, q, r, s, t, u ,v, w ,x ,y ,z};
  31. int b = 0;
  32. cout Ninput[b]
  33. b++;
  34. }
  35. cout << " is this a good solution? y/n >> ";
  36. char yn;
  37. cin >> yn;
  38. if(yn == y) {
  39. EndThisShit = true;
  40. }
  41. if(yn == n) {
  42. EndThisShit = false;
  43. }
  44. }while(!EndThisShit);
  45. }
Last edited by kangarooblood; Jul 4th, 2009 at 7:25 am.
Similar Threads
Reputation Points: 6
Solved Threads: 2
Light Poster
kangarooblood is offline Offline
42 posts
since Jun 2009
Jul 4th, 2009
0

Re: substitution cipher help

What is it supposed to do. Maybe you can give sample input, current (incorrect) output, and expected output.
Featured Poster
Reputation Points: 437
Solved Threads: 204
Posting Virtuoso
daviddoria is offline Offline
1,968 posts
since Feb 2008
Jul 4th, 2009
0

Re: Substitution cipher help

Click to Expand / Collapse  Quote originally posted by daviddoria ...
What is it supposed to do. Maybe you can give sample input, current (incorrect) output, and expected output.
well it's supposed to give differet solutions to a Substitution cipher (http://en.wikipedia.org/wiki/Substitution_cipher)
it should be writing a possible solutions and if it's the correct then finish it of, and if it's not it shall give another suggestion, until it finds the right one. right now nothing happends, all I get is an error message saying " `width' has not been declared" it's supposed to give every letter a specific array, then convert it to numbers, then add an increasing number to the letter number, then convert it back to the letter that is the increasing number after it. and then type it out.

c++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2. #include <time.h>
  3. #include <windows.h>
  4. #include <iomanip.h>
  5. #include <string.h>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.  
  12.  
  13. bool EndThisShit(false);
  14. do {
  15. char input;
  16. cin >> input;
  17. int Ninput[1000];
  18. int li;
  19. li = input.width();
  20. Ninput[1000] = input;
  21. int Veckt[li];
  22. int fo=0;
  23. int letters[fo];
  24.  
  25. int y;
  26. for(y = 0; y < li; y++){
  27. int t =1;
  28. Veckt[fo] = Ninput[fo] + t;
  29. Veckt[fo] = (char)letters[fo];
  30. fo++;
  31. t++;
  32. }
  33. int a;
  34. for(a = 0; a < li; a++) {
  35. int bo = 0;
  36. cout << letters[fo];
  37. bo++;
  38. }
  39. cout << " is this a good solution? y/n >> ";
  40. char yn;
  41. cin >> yn;
  42. if(yn == 'y') {
  43. EndThisShit = true;
  44. }
  45. if(yn == 'n') {
  46. EndThisShit = false;
  47. }
  48. }while(!EndThisShit);
  49. }

New code!
Last edited by kangarooblood; Jul 4th, 2009 at 9:54 am.
Reputation Points: 6
Solved Threads: 2
Light Poster
kangarooblood is offline Offline
42 posts
since Jun 2009
Jul 4th, 2009
0

Re: substitution cipher help

What are all those headers for? Comments would also be nice so we can see what your doing.
Are you incrementing every character by one, and if the input is 'n', you increment every number again? What happens when you go past the printible character range?
Reputation Points: 431
Solved Threads: 17
Posting Whiz in Training
Hiroshe is offline Offline
255 posts
since Jun 2008
Jul 5th, 2009
0

Re: substitution cipher help

Click to Expand / Collapse  Quote originally posted by Hiroshe ...
What are all those headers for? Comments would also be nice so we can see what your doing.
Are you incrementing every character by one, and if the input is 'n', you increment every number again? What happens when you go past the printible character range?
well I'm going to use the headers later, like adding some color and so on. And when I overcome the printable range (for the moment) nothing happends, then it's just not a substitution cipher and it's just to close the window down.
Reputation Points: 6
Solved Threads: 2
Light Poster
kangarooblood is offline Offline
42 posts
since Jun 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: hey guys could u check my code PLEASE its a code with a "text file"
Next Thread in C++ Forum Timeline: Segmentation Fault





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC