Recent

Author Topic: jules cesar cryptographie program erreur  (Read 4682 times)

whitehat

  • Jr. Member
  • **
  • Posts: 93
jules cesar cryptographie program erreur
« on: April 07, 2017, 12:08:01 am »
i have some exam about the cryptographie (jules cesar ) when i run my program there's some problem in ligne
33
Code: Pascal  [Select][+][-]
  1. program ex;
  2. uses wincrt;
  3. type
  4. tab=array[1..26] of string;
  5. var
  6. t,t2:tab;
  7. a,i:integer;
  8. chra,ch,ch2:string;
  9. begin
  10. writeln('     __      .__');
  11. writeln('    |__|__ __|  |   ____   ______   ____  ____   ___________ _______');
  12. writeln('    |  |  |  \  | _/ __ \ /  ___/ _/ ___\/ __ \ /  ___/\__  \\_  __ \');
  13. writeln('    |  |  |  /  |_\  ___/ \___ \  \  \__\  ___/ \___ \  / __ \|  | \/');
  14. writeln('/\__|  |____/|____/\___  >____  >  \___  >___  >____  >(____  /__|');  
  15. writeln('\______|               \/     \/       \/    \/     \/      \/');
  16. a:=64;
  17. ch:='';
  18. for i:=1 to 26 do
  19. t[i]:=chr(a+i);
  20. for i:=1 to 26 do
  21. begin
  22. ch:=ch+t[i];
  23. end;
  24. ch2:=copy(ch,1,3);
  25. delete(ch,1,3);
  26. ch:=ch+ch2;
  27. for i:=1 to 26 do
  28. begin
  29. t2[i]:=t2[i]+ch[i];
  30. end;
  31. for i:=1 to 26 do
  32. begin
  33. if (ord(t[i]))=(ord(t2[i])+3) then
  34. chra:=t2[i];
  35. end;
  36. for i:=1 to 26 do
  37. write(t[i]:2);
  38. writeln;
  39. for i:=1 to 26 do
  40. write(t2[i]:2);
  41. end.
  42.  
  43.  

jmm72

  • Jr. Member
  • **
  • Posts: 79
  • Very experienced in being a beginner...
Re: jules cesar cryptographie program erreur
« Reply #1 on: April 07, 2017, 01:07:29 am »
The function Ord() only works with ordinal types, like Char. However you've declared type 'tab' to be array of string, which is not ordinal.

You use some concatenation in the array elements so I'll tell you to keep them as string, and when using Ord() access just the first character (which I guess it's the valid one, I've not bothered to follow your program logic) using index [1]:

Code: Pascal  [Select][+][-]
  1. if (ord(t[i][1]))=(ord(t2[i][1])+3) then
Lazarus 1.6.4 + FPC 3.0.2 64bits under Windows 7 64bits
Only as a hobby nowadays
Current proyect release: TBA

whitehat

  • Jr. Member
  • **
  • Posts: 93
Re: jules cesar cryptographie program erreur
« Reply #2 on: April 07, 2017, 07:56:26 am »
hello dude this is the methode of jules césar of cryptographie : http://www.nymphomath.ch/crypto/cesar/index.html

jmm72

  • Jr. Member
  • **
  • Posts: 79
  • Very experienced in being a beginner...
Re: jules cesar cryptographie program erreur
« Reply #3 on: April 07, 2017, 10:16:31 am »
I know the Cesar cypher, I fixed your code and it seems to work here. I just mentioned that I don't know why you chose to do a concatenation forcing you to declare the array elements as string.
Lazarus 1.6.4 + FPC 3.0.2 64bits under Windows 7 64bits
Only as a hobby nowadays
Current proyect release: TBA

JD

  • Hero Member
  • *****
  • Posts: 1913
Re: jules cesar cryptographie program erreur
« Reply #4 on: April 07, 2017, 10:21:04 am »
hello dude this is the methode of jules césar of cryptographie : http://www.nymphomath.ch/crypto/cesar/index.html

J'espère qu'il peut lire le français.  :D
Linux Mint - Lazarus 4.6/FPC 3.2.2,
Windows - Lazarus 4.6/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

whitehat

  • Jr. Member
  • **
  • Posts: 93
Re: jules cesar cryptographie program erreur
« Reply #5 on: April 07, 2017, 01:29:46 pm »
 tkt pas frere  je parle bien le francais  :D

whitehat

  • Jr. Member
  • **
  • Posts: 93
Re: jules cesar cryptographie program erreur
« Reply #6 on: April 07, 2017, 01:32:33 pm »
jmm72 can you send me the program if you fix it please

jmm72

  • Jr. Member
  • **
  • Posts: 79
  • Very experienced in being a beginner...
Re: jules cesar cryptographie program erreur
« Reply #7 on: April 07, 2017, 03:18:32 pm »
Do you really need me to paste the line 33 I fixed in my reply into your code?

Also, I think a couple more language boards would be good for the forum, german and french for example.

Code: Pascal  [Select][+][-]
  1. program ex;
  2. uses wincrt;
  3. type
  4. tab=array[1..26] of string;
  5. var
  6. t,t2:tab;
  7. a,i:integer;
  8. chra,ch,ch2:string;
  9. begin
  10. writeln('     __      .__');
  11. writeln('    |__|__ __|  |   ____   ______   ____  ____   ___________ _______');
  12. writeln('    |  |  |  \  | _/ __ \ /  ___/ _/ ___\/ __ \ /  ___/\__  \\_  __ \');
  13. writeln('    |  |  |  /  |_\  ___/ \___ \  \  \__\  ___/ \___ \  / __ \|  | \/');
  14. writeln('/\__|  |____/|____/\___  >____  >  \___  >___  >____  >(____  /__|');  
  15. writeln('\______|               \/     \/       \/    \/     \/      \/');
  16. a:=64;
  17. ch:='';
  18. for i:=1 to 26 do
  19. t[i]:=chr(a+i);
  20. for i:=1 to 26 do
  21. begin
  22. ch:=ch+t[i];
  23. end;
  24. ch2:=copy(ch,1,3);
  25. delete(ch,1,3);
  26. ch:=ch+ch2;
  27. for i:=1 to 26 do
  28. begin
  29. t2[i]:=t2[i]+ch[i];
  30. end;
  31. for i:=1 to 26 do
  32. begin
  33. if (ord(t[i][1]))=(ord(t2[i][1])+3) then
  34. chra:=t2[i];
  35. end;
  36. for i:=1 to 26 do
  37. write(t[i]:2);
  38. writeln;
  39. for i:=1 to 26 do
  40. write(t2[i]:2);
  41. end.
Lazarus 1.6.4 + FPC 3.0.2 64bits under Windows 7 64bits
Only as a hobby nowadays
Current proyect release: TBA

whitehat

  • Jr. Member
  • **
  • Posts: 93
Re: jules cesar cryptographie program erreur
« Reply #8 on: April 07, 2017, 03:29:49 pm »
thx you man when i need you i find you here ;)  you help me alot

 

TinyPortal © 2005-2018