2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【電脳少女プログラミング2088 ─壊レタ君を再構築─】D:ネオン街の裏路地やってみた。

Posted at

はじめに

paizaの新作プログラミングゲーム【電脳少女プログラミング2088 ─壊レタ君を再構築─】で、ネオン街の裏路地(paizaランク:D相当)の課題に挑戦しました。

問題

あなたは裏路地にある扉を開けようとしています。扉は n 個あり、各扉には順不同に数字が書かれています。最も大きな扉の数字を出力してください。

解答

package main

import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    
    scanner.Scan()
    num, _ := strconv.Atoi(scanner.Text())
    
    max := 0
    for i := 0; i < num; i++ {
        scanner.Scan()
        n, _ := strconv.Atoi(scanner.Text())
        if max < n {
            max = n
        }
    }
    
    fmt.Println(max)

今回学んだこと

string型からint型に変換する方法

n, _ := strconv.Atoi(scanner.Text())

, _ はエラー文を記入する欄であり_は省略している

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?