Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "strconv"
- )
- func main() {
- var x, y, eatenPieces int
- fmt.Scanln(&x)
- fmt.Scanln(&y)
- var cakePieces = x * y
- var input string
- fmt.Scanln(&input)
- for cakePieces > 0 && input != "STOP" {
- eatenPieces,_ = strconv.Atoi(input)
- cakePieces -= eatenPieces
- fmt.Scanln(&input)
- }
- if cakePieces >= 0 {
- fmt.Printf("%d pieces are left.\n", cakePieces)
- } else {
- fmt.Printf("No more cake left! You need %d pieces more.\n", cakePieces * -1)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement