DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   substitution cipher help (http://www.daniweb.com/forums/thread201625.html)

kangarooblood Jul 4th, 2009 6:58 am
substitution cipher help
 
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.

#include <iostream>
#include <time.h>
#include <windows.h>
#include <iomanip.h>
#include <string.h>

using namespace std;

int main()
{
   
   
    bool EndThisShit(false);
    do {
    string input;
    cin >> input;
    int il;
    input.length() = il;
    int Ninput[il];
    Ninput[il] = input
    int y;
    for( y = 0; y < il; y++){
    int t =1;
    Ninput[fo] + t;
    i++;
    t++;
}
 int a;
 for(a = 0; a < il; a++) {
      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};
      int b = 0;
      cout Ninput[b]
      b++;
      }   
      cout << " is this a good solution? y/n >> ";
      char yn;
      cin >> yn;
      if(yn == y) {
            EndThisShit = true;
            }
      if(yn == n) {
            EndThisShit = false;
            }
}while(!EndThisShit);
}

daviddoria Jul 4th, 2009 8:43 am
Re: substitution cipher help
 
What is it supposed to do. Maybe you can give sample input, current (incorrect) output, and expected output.

kangarooblood Jul 4th, 2009 9:25 am
Re: Substitution cipher help
 
Quote:

Originally Posted by daviddoria (Post 908204)
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.

#include <iostream>
#include <time.h>
#include <windows.h>
#include <iomanip.h>
#include <string.h>

using namespace std;

int main()
{
   
   
    bool EndThisShit(false);
    do {
    char input;
    cin >> input;
    int Ninput[1000];
    int li;
    li = input.width();
    Ninput[1000] = input;
    int Veckt[li];
    int fo=0;
    int letters[fo];
   
    int y;
    for(y = 0; y < li; y++){
    int t =1;
    Veckt[fo] = Ninput[fo] + t;
    Veckt[fo] = (char)letters[fo];
    fo++;
    t++;
}
 int a;
 for(a = 0; a < li; a++) {
      int bo = 0;
      cout << letters[fo];
      bo++;
      }   
      cout << " is this a good solution? y/n >> ";
      char yn;
      cin >> yn;
      if(yn == 'y') {
            EndThisShit = true;
            }
      if(yn == 'n') {
            EndThisShit = false;
            }
}while(!EndThisShit);
}

New code!

Hiroshe Jul 4th, 2009 11:43 am
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?

kangarooblood Jul 5th, 2009 4:17 am
Re: substitution cipher help
 
Quote:

Originally Posted by Hiroshe (Post 908296)
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.


All times are GMT -4. The time now is 9:59 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC