first commit
This commit is contained in:
63
strings.go
Normal file
63
strings.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/gofiber/fiber"
|
||||
)
|
||||
|
||||
func esPalindromo(s string) bool {
|
||||
// Convertir la cadena a minúsculas y eliminar espacios en blanco
|
||||
s = strings.ToLower(strings.ReplaceAll(s, " ", ""))
|
||||
|
||||
//Verificar si la cadena es un palindromo
|
||||
for i := 0; i < len(s)/2; i++ {
|
||||
if s[i] != s[len(s)-i-1] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func esIgual(s1, s2 string) bool {
|
||||
return s1 == s2
|
||||
}
|
||||
|
||||
func mayusculas(s string) string {
|
||||
return strings.ToUpper(s)
|
||||
}
|
||||
|
||||
func minusculas(s string) string {
|
||||
return strings.ToLower(s)
|
||||
}
|
||||
|
||||
func main() {
|
||||
app := fiber.New()
|
||||
|
||||
app.Get("/esPalindromo", func(c *fiber.Ctx) {
|
||||
str := c.Query("cadena")
|
||||
result := esPalindromo(str)
|
||||
c.SendString("Es palíndromo: ", result)
|
||||
})
|
||||
|
||||
app.Get("/esIgual", func(c *fiber.Ctx) {
|
||||
str1 := c.Query("cadena1")
|
||||
str2 := c.Query("cadena2")
|
||||
result := esIgual(str1, str2)
|
||||
c.SendString("Son iguales: ", result)
|
||||
})
|
||||
|
||||
app.Get("/mayusculas", func(c *fiber.Ctx) {
|
||||
str := c.Query("cadena")
|
||||
result := mayusculas(str)
|
||||
c.SendString("Mayúsculas: ", result)
|
||||
})
|
||||
|
||||
app.Get("/minusculas", func(c *fiber.Ctx) {
|
||||
str := c.Query("cadena")
|
||||
result := minusculas(str)
|
||||
c.SendString("Minúsculas: ", result)
|
||||
})
|
||||
|
||||
app.Listen(3000)
|
||||
}
|
||||
Reference in New Issue
Block a user