Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- static class mot_pallindrome
- {
- public static string espace( string s)
- {
- int n, lg; //compteur
- lg = s.Length;
- string chaine_e = "";
- for(n = 0; n <lg; n = n+1)
- {
- if( s[n] != ' ')
- {
- chaine_e = chaine_e + s[n];
- }
- }
- return chaine_e;
- }
- public static string mirroir(string chaine_e)
- {
- int n; //compteur de ligne
- string chainef = ""; //chaine à renvoyer
- for( n = chaine_e.Length-1; n >= 0; n = n - 1)
- {
- chainef = chainef + chaine_e[n];
- }
- return chainef;
- }
- public static string comparaison (string chaine_e, string chainef)
- {
- string reponse = "";
- if(chainef.CompareTo(chaine_e) < 0 or > 0)
- {
- reponse = reponse + "Ce texte n'est un palindrome";
- }
- else
- reponse = reponse + "Ce texte n'est pas un palindrome";
- return reponse;
- }
- static void Main()
- {
- string s = "", chaine_e, chainef;
- chaine_e = espace(s);
- chainef = mirroir(chaine_e);
- Console.Write("Votre texte ? : ");
- s = Console.ReadLine();
- Console.Write("{0}", comparaison(chaine_e, chainef));
- }
- }
Add Comment
Please, Sign In to add comment