Go言語 switch

package main

import "fmt"

func main() {
    var score int
    fmt.Println("Score?")
    fmt.Scanf("%d", &score)

    if score >= 90 {
        fmt.Println("A!")
    } else if score >= 70 {
        fmt.Println("B!")
    } else {
        fmt.Println("C!")
    }

    switch{
    case score >= 90:
        fmt.Println("A!")
    case score >= 70:
        fmt.Println("B!")
    default:
        fmt.Println("C!")
    }
}

投稿者: chosuke

趣味はゲームやアニメや漫画などです

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です