Created
March 28, 2018 15:44
-
-
Save halllllll/208b199d76157194a32a5abe59a7439b to your computer and use it in GitHub Desktop.
runeってかbyteだけどそれを利用してアルファベットをaから作るやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main(){ | |
fmt.Println("アルファベット文字列の辞書順について.") | |
// 要はrune(byte)なのでアルファベット全部生成できないか? | |
alp := "a" | |
for _, v := range alp{ | |
fmt.Println(v) | |
fmt.Printf("%T\n", v) | |
fmt.Println(int(v)) | |
fmt.Println(string(int(v))) | |
fmt.Println(string(int(v)+1)) | |
} | |
fmt.Println("ということは") | |
cur := []byte(alp) | |
fmt.Println(cur) | |
fmt.Println(cur[0]) | |
fmt.Println(int(cur[0])+1) | |
fmt.Println(string(int(cur[0]))) | |
fmt.Println(string(int(cur[0])+1)) | |
fmt.Println("なので順々にたしていけばよいのではないか") | |
alphabet := make([]string, 0) | |
for ccur:=[]byte(alp);10<ccur[0];ccur[0]+=1{ | |
// breakするとこの条件はいろいろある アルファペットの数27を利用したりstring()してzだったり | |
alphabet = append(alphabet, string(ccur[0])) | |
if string(ccur[0])=="z"{ | |
break | |
} | |
} | |
fmt.Println(alphabet) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment