Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "unicode"
- )
- func change_char(j, x int, s string) string {
- runes:=[]rune(s)
- if unicode.IsLower(runes[j]) && x %2 != 0 {
- if x == 1 {
- runes[j] = unicode.ToUpper(runes[j])
- }else {
- amount := x/2 + 1
- runes[j] = unicode.ToUpper(runes[j] + amount)}
- } else if unicode.IsLower(runes[j]) && x%2 == 0 {
- if x == 2 {
- runes[j] = unicode.ToLower(runes[j]+1)
- } else {
- amount := x/2
- runes[j] = unicode.ToLower(runes[j]+amount)
- }
- } else if unicode.IsUpper(runes[j]) && x%2 != 0 {
- amount := x/2 + 1
- runes[j] = unicode.ToLower(runes[j]+amount)
- }else if unicode.IsUpper(runes[j]) && x%2 == 0 {
- amount := x/2
- runes[j] = unicode.ToUpper(runes[j]+amount)
- }
- return string (runes)
- }
- func main() {
- var s string
- var q int
- fmt.Scanf("%s", &s)
- fmt.Scanf("%d", &q)
- var l, r , x int
- for i:=0 ; i < q ; i ++ {
- fmt.Scanf("%d %d %d", &l, &r, &x)
- for j:=l-1; j < r ; j++ {
- s = change_char(j, x, s)
- }
- }
- fmt.Println("s = ", s)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement