0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

paiza.ioでgo その16

0
Posted at

概要

paiza.ioでgoやってみた。
練習問題、やってみた。

練習問題

湯婆婆を実装せよ。

サンプルコード

package main
import (
	"bufio"
	"fmt"
	"math/rand"
	"os"
	"strings"
	"time"
)
func main() {
	fmt.Println("契約書だよ。そこに名前を書きな。")
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	name := stdin.Text()
	fmt.Printf("フン。%sというのかい。贅沢な名だねぇ。\n", name)
	nameArray := strings.Split(name, "")
	rand.Seed(time.Now().UnixNano())
	newname := nameArray[rand.Intn(len(nameArray))]
	fmt.Printf("今からお前の名前は%sだ。いいかい、%sだよ。分かったら返事をするんだ、%s!!\n", newname, newname, newname)
}


成果物

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?