Ahh i get you thanx for all of your help by the way.
Do you think i could do something like:
But then i would be puzzeled about what goes after the modulus.Code:for (int i = 0; i != alphabet_size; ++i) { cyphertext += ( ( (plainchar[i] - '0' | 'A' | 'a') + shift) %) + '0' | 'A' | 'a'; plainchar2 += cyphertext[i] - shift; }
No, it could not be. How on earth is the compiler supposed to know when to use what?
You need a function. Learn about functions. And you need the contents of the <cctype> standard header to classify characters.
After the modulus you need the size of the class, i.e. 26 for alphabetic characters, 10 for digits.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
It was just a guess really.I guess i could try read in each char 1 at a time and use its corrisponding type('a' | 'A' | '0').What do you think of that?
Last edited by L_U_K_E; 06-28-2006 at 09:25 AM.
???Originally Posted by L_U_K_E
And yes, for each character type you need to determine what kind of character it is and do the shift for that. Or you could Aplly to ceasar cypher to entiere ascii set (or better the entire ascii set apart from null), it wouldn't necessarily be printable but as far as the information stored goes it would work.
Well, you'll need to test if a character is
# 'a' to 'z'
# 'A' to 'Z'
# '0' to '9'
And do a seperate dingo for each one. Again, when you decrypt (or more accurately decode), check if the character is
# 'a'+3 to 'z'+3
and so on.
Code:#include <stdio.h> void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){ puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9 /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i] ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][ t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}