This is the 14th day of my participation in the November Gwen Challenge. Check out the event details: The last Gwen Challenge 2021
【PTA group Program Design Ladder Competition 】
Eat fish or meat L1-063 (10) the Go | Golang
The country gave a standard height of 130 centimeters and a standard weight of 27 kilograms for an 8-year-old boy. The standard height for an 8-year-old girl is 129 centimeters and the standard weight is 25 kilograms.
Now you have to give advice on supplementary nutrition according to the baby’s height and weight.
Input format:
The input gives a positive integer N of up to 10 on the first line, followed by N lines, each giving one child’s physical data:
Sex height weightCopy the code
Where the gender is 1 for boys and 0 for girls. Height and weight are positive whole numbers up to 200.
Output format:
For each baby, give your advice in one line:
- If too short, output: Duo Chi Yu! Eat more fish
- If too thin, output: Duo Chi Rou! Eat more meat
- If positive, output: wan Mei! Perfect;
- If it’s too high, output: ni Li Hai! You’re good.
- If too fat, output: Shao Chi Rou! Eat less meat.
Evaluate height first, then weight. There should be a space between two sentences.
Input Example 1:
4
0 130 23
1 129 27
1 130 30
0 128 27
Copy the code
No blank line at the end
Example 1:
ni li hai! duo chi rou!
duo chi yu! wan mei!
wan mei! shao chi rou!
duo chi yu! shao chi rou!
Copy the code
No blank line at the end
Ideas:
Basic judgment, first separate men and women, and then split body height and weight, and then output.
The code is as follows:
package main
import "fmt"
func main(a) {
var N int
_,_=fmt.Scan(&N)
for i:=0; i<N; i++{var sex,tall,weight int
_,_ = fmt.Scan(&sex,&tall,&weight)
if sex==1 {
if tall>130 {
fmt.Printf("ni li hai!")}else if tall==130 {
fmt.Printf("wan mei!")}else{
fmt.Printf("duo chi yu!")}if weight>27 {
fmt.Printf("shao chi rou!")}else if weight==27 {
fmt.Printf("wan mei!")}else{
fmt.Printf("duo chi rou!")}}else {
if tall > 129 {
fmt.Printf("ni li hai!")}else if tall == 129 {
fmt.Printf("wan mei!")}else {
fmt.Printf("duo chi yu!")}if weight > 25 {
fmt.Printf("shao chi rou!")}else if weight == 25 {
fmt.Printf("wan mei!")}else {
fmt.Printf("duo chi rou!")}}ifi ! = N- 1 {
fmt.Println()
}
}
}
Copy the code