substitution cipher help

Reply

Join Date: Jun 2009
Posts: 38
Reputation: kangarooblood is an unknown quantity at this point 
Solved Threads: 2
kangarooblood kangarooblood is offline Offline
Light Poster

substitution cipher help

 
0
  #1
Jul 4th, 2009
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.

  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.
// Maybe you like C++ put I prefer A++...
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 625
Reputation: daviddoria is a jewel in the rough daviddoria is a jewel in the rough daviddoria is a jewel in the rough 
Solved Threads: 46
daviddoria daviddoria is offline Offline
Practically a Master Poster

Re: substitution cipher help

 
0
  #2
Jul 4th, 2009
What is it supposed to do. Maybe you can give sample input, current (incorrect) output, and expected output.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 38
Reputation: kangarooblood is an unknown quantity at this point 
Solved Threads: 2
kangarooblood kangarooblood is offline Offline
Light Poster

Re: Substitution cipher help

 
0
  #3
Jul 4th, 2009
Originally Posted by daviddoria View Post
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.

  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.
// Maybe you like C++ put I prefer A++...
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 255
Reputation: Hiroshe is a jewel in the rough Hiroshe is a jewel in the rough Hiroshe is a jewel in the rough Hiroshe is a jewel in the rough 
Solved Threads: 16
Hiroshe's Avatar
Hiroshe Hiroshe is offline Offline
Posting Whiz in Training

Re: substitution cipher help

 
0
  #4
Jul 4th, 2009
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?
"Sometimes, when I lie in bed at night and look up at the stars, I think to myself, "Man! I really need to fix that roof."-Jack Handy
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 38
Reputation: kangarooblood is an unknown quantity at this point 
Solved Threads: 2
kangarooblood kangarooblood is offline Offline
Light Poster

Re: substitution cipher help

 
0
  #5
Jul 5th, 2009
Originally Posted by Hiroshe View Post
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.
// Maybe you like C++ put I prefer A++...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC