📜  hackerrank golang bon appetit - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:43.306000             🧑  作者: Mango

代码示例1
func bonAppetit(bill []int32, k int32, b int32) {
     var anna, notPaid int32
     notPaid = bill[k]
     
     for i := 0; int32(i) < int32(len(bill)); i++ {
         if bill[i] < notPaid {
           anna += bill[i]
         } 
     } 
    
     divide := anna - bill[k] / 2
     subtract := b - int32(divide)
     
     var result interface{}
     
     if subtract > 0 {
       result = subtract
     } else {
       result = "Bon Appetit"
     }
     
    fmt.Println(result)
}