Facebook
From ededed, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 129
  1. # Définir la chaîne initiale
  2. $chaine = "Salut"
  3.  
  4. # Parcourir chaque caractère dans la chaîne
  5. for ($i = 0; $i -lt $chaine.Length; $i++) {
  6.     # Si l'index est pair, convertir en majuscule
  7.     if ($i % 2 -eq 0) {
  8.         $chaine = $chaine.Substring(0, $i) + $chaine.Substring($i, 1).ToUpper() + $chaine.Substring($i + 1)
  9.     }
  10. }
  11.  
  12. # Afficher le résultat
  13. Write-Host $chaine
  14.