Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

If worsening, use command line parameters to find the mean.

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "such as worsening the use of command-line parameters to find the mean". The explanation in the article is simple and clear, and is easy to learn and understand. let's study and learn "such as worsening the use of command-line parameters to find the average"!

Package mainimport ("fmt"log"os"strconv") func average (numbers... float64) float64 {var sum float64 = 0 for _, number: = range numbers {sum + = number} return sum / float64 (len (numbers))} func main () {arguments: = os.Args [1:] var numbers [] float64 for _ Argument: = range arguments {number, err: = strconv.ParseFloat (argument, 64) if err! = nil {log.Fatal (err)} numbers = append (numbers, number)} fmt.Printf ("Average value is% 0.2f", average (numbers...))}

[root@VM-centos ~ / average] #. / main 100 200 300

Average value is 200.00

Thank you for your reading, the above is the content of "if worsening the use of command-line parameters to find the mean". After the study of this article, I believe you have a deeper understanding of the problem of using command-line parameters to find the mean. The specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report