mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
802 B
38 lines
802 B
5 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
5 years ago
|
func firstNotVowel(letters []rune) int {
|
||
|
index := 0
|
||
|
for i := 0; i < len(letters); i++ {
|
||
|
if letters[i] == 'a' || letters[i] == 'e' || letters[i] == 'i' || letters[i] == 'o' || letters[i] == 'u' ||
|
||
|
letters[i] == 'A' || letters[i] == 'E' || letters[i] == 'I' || letters[i] == 'O' || letters[i] == 'U' {
|
||
|
return index
|
||
|
}
|
||
|
index++
|
||
|
}
|
||
|
return 0
|
||
|
}
|
||
|
|
||
5 years ago
|
func main() {
|
||
|
if len(os.Args) != 2 || os.Args[1] == "" {
|
||
5 years ago
|
fmt.Println()
|
||
5 years ago
|
return
|
||
|
}
|
||
|
letters := []rune(os.Args[1])
|
||
|
switch letters[0] {
|
||
|
case 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U':
|
||
|
fmt.Print(os.Args[1] + "ay\n")
|
||
|
default:
|
||
|
start := firstNotVowel(letters)
|
||
|
if start == 0 {
|
||
|
fmt.Println("No vowels")
|
||
|
} else {
|
||
|
fmt.Print(string(letters[start:]) + string(letters[:start]) + "ay\n")
|
||
|
}
|
||
|
}
|
||
|
}
|