Advertisement
anushervon111

Untitled

Mar 31st, 2025
576
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.03 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.    
  6.     "unicode"
  7. )
  8.  
  9.  
  10. func change_char(j, x int, s string) string {
  11.     runes:=[]rune(s)
  12.    
  13.     if unicode.IsLower(runes[j]) && x %2 != 0 {
  14.         if x == 1 {
  15.             runes[j] = unicode.ToUpper(runes[j])
  16.         }else {
  17.         amount := x/2 + 1
  18.         runes[j] = unicode.ToUpper(runes[j] + amount)}
  19.     } else if unicode.IsLower(runes[j]) && x%2 == 0 {
  20.         if x == 2 {
  21.             runes[j] = unicode.ToLower(runes[j]+1)
  22.         } else {
  23.             amount := x/2
  24.             runes[j] = unicode.ToLower(runes[j]+amount)
  25.         }  
  26.     } else if unicode.IsUpper(runes[j]) && x%2 != 0 {
  27.         amount := x/2 + 1
  28.         runes[j] = unicode.ToLower(runes[j]+amount)
  29.     }else if unicode.IsUpper(runes[j]) && x%2 == 0 {
  30.         amount := x/2
  31.         runes[j] = unicode.ToUpper(runes[j]+amount)
  32.     }
  33.     return string (runes)
  34. }
  35. func main() {
  36.     var s string
  37.     var q int
  38.     fmt.Scanf("%s", &s)
  39.     fmt.Scanf("%d", &q)
  40.  
  41.     var l, r , x int
  42.     for i:=0 ; i < q ; i ++ {
  43.         fmt.Scanf("%d %d %d", &l, &r, &x)
  44.         for j:=l-1; j < r ; j++ {
  45.             s = change_char(j, x, s)
  46.         }
  47.        
  48.     }
  49.     fmt.Println("s = ", s)
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement