Guest User

Untitled

a guest
Jan 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. using System;
  2.  
  3. static class mot_pallindrome
  4. {
  5.  
  6. public static string espace( string s)
  7. {
  8. int n, lg; //compteur
  9. lg = s.Length;
  10. string chaine_e = "";
  11.  
  12. for(n = 0; n <lg; n = n+1)
  13. {
  14. if( s[n] != ' ')
  15. {
  16. chaine_e = chaine_e + s[n];
  17. }
  18. }
  19. return chaine_e;
  20. }
  21.  
  22.  
  23. public static string mirroir(string chaine_e)
  24. {
  25. int n; //compteur de ligne
  26. string chainef = ""; //chaine à renvoyer
  27.  
  28. for( n = chaine_e.Length-1; n >= 0; n = n - 1)
  29. {
  30. chainef = chainef + chaine_e[n];
  31. }
  32.  
  33. return chainef;
  34. }
  35.  
  36. public static string comparaison (string chaine_e, string chainef)
  37. {
  38. string reponse = "";
  39.  
  40. if(chainef.CompareTo(chaine_e) < 0 or > 0)
  41. {
  42. reponse = reponse + "Ce texte n'est un palindrome";
  43. }
  44. else
  45. reponse = reponse + "Ce texte n'est pas un palindrome";
  46.  
  47. return reponse;
  48. }
  49.  
  50. static void Main()
  51. {
  52. string s = "", chaine_e, chainef;
  53. chaine_e = espace(s);
  54. chainef = mirroir(chaine_e);
  55.  
  56. Console.Write("Votre texte ? : ");
  57. s = Console.ReadLine();
  58. Console.Write("{0}", comparaison(chaine_e, chainef));
  59. }
  60.  
  61.  
  62.  
  63. }
Add Comment
Please, Sign In to add comment