Go language programming-Calculate the number of roosters and hens in a maximum of one hundred chicks

package main

import (
“fmt”
)

func main() { //Buy a total of 100, so cock (chicken weng) up to 20, hen (chicken mother) up to 33, chicken (chicken) up to 100 for cock := 0; cock <20; cock++ { for hen := 0; hen <33; hen++ { for chicken := 0; chicken <= 100; chicken += 3 { if (5 cock+3 hen+chicken/3 == 100 && cock+hen+chicken == 100) { fmt.Printf("%d chicken, %d chicken, %d chicken\n", cock, hen, chicken) } } } } }











Insert picture description here

Guess you like

Origin blog.csdn.net/m0_38127487/article/details/114173207