Created
March 14, 2017 22:43
-
-
Save artivnv/3dc3fc82d21c89dd18b933ccac46f37f to your computer and use it in GitHub Desktop.
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() { | |
var a float64 | |
var b, c string | |
fmt.Print("Введите длину: ") | |
fmt.Scanln(&a) | |
fmt.Print("Введите её единицу измерения (м/дм/см/мм): ") | |
fmt.Scanln(&b) | |
if b == "м" { | |
a = a * 1 | |
} else if b == "дм" { | |
a = a * 0.1 | |
} else if b == "см" { | |
a = a * 0.01 | |
} else if b == "мм" { | |
a = a * 0.001 | |
} else { | |
fmt.Println("Ошибка, я не знаю таких величин") | |
return | |
} | |
fmt.Print("В какую единицу вы хотите её перевести (м/дм/см/мм)? ") | |
fmt.Scanln(&c) | |
if c == "м" { | |
a = a * 1 | |
} else if c == "дм" { | |
a = a * 10 | |
} else if c == "см" { | |
a = a * 100 | |
} else if c == "мм" { | |
a = a * 1000 | |
} else { | |
fmt.Println("Ошибка, я не знаю таких величин") | |
return | |
} | |
fmt.Println("Результат перевода:", a, c) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment