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.
39 lines
834 B
39 lines
834 B
package main |
|
|
|
import ( |
|
"fmt" |
|
"os" |
|
|
|
"github.com/01-edu/z01" |
|
) |
|
|
|
func main() { |
|
if len(os.Args) != 2 || os.Args[1] == "" { |
|
z01.PrintRune('\n') |
|
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") |
|
} |
|
} |
|
} |
|
|
|
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 |
|
}
|
|
|