francouas
Messages postés16Date d'inscriptionmardi 24 février 2009StatutMembreDernière intervention21 décembre 2009
-
25 févr. 2009 à 18:21
cs_Bidou
Messages postés5487Date d'inscriptiondimanche 4 août 2002StatutMembreDernière intervention20 juin 2013
-
25 févr. 2009 à 21:59
je pense que ma fonction est bonne mais le main est incomplet
comment appeller la fonction correctement pour qu'il affiche si c'est un palindrome ou pas ?
merci pour votre 2ieme aide de la journée ;-)
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string mot;
Console.WriteLine("entrer un mot");
mot = Console.ReadLine();
string palindrome = IsPal(mot);
Console.WriteLine("c'est un palindrome");
}
public static bool IsPal(string s)
{
int length = s.Length - 1;
if (length > 0)
{
if (s[0] == s[length])
{
s = s.Substring(1, length - 1);
return IsPal(s);
}
return false;
}
return true;
}
}
}