Golang程序,使用二进制运算符将大写字母转换为小写字母。
示例
package main import "fmt" func main(){ fmt.Printf("使用OR运算符从大写字母打印小写字母: ") for ch:='A'; ch<='Z'; ch++ { fmt.Printf(string(ch | ' ')) } fmt.Println() fmt.Printf("Printing Uppercase characters from Lowercase characters using AND operator: ") for ch:='a'; ch<='z'; ch++ { fmt.Printf(string(ch & '_')) } }输出结果
使用OR运算符从大写字母打印小写字母: abcdefghijklmnopqrstuvwxyz Printing Uppercase characters from Lowercase characters using AND operator: ABCDEFGHIJKLMNOPQRSTUVWXYZ