今天有點(diǎn)忙,學(xué)習(xí)的有些晚冗茸,也有些少席镀。今天主要是了解函數(shù),知道同一文件內(nèi)夏漱,函數(shù)名不能重復(fù)豪诲,main作為主函數(shù)用來(lái)顯示主體內(nèi)容,類似于index.html在網(wǎng)頁(yè)的地位挂绰,但別的函數(shù)也能輸出內(nèi)容屎篱。
學(xué)習(xí)代碼如下:
package main
import "fmt"
const (
second =60
minter=second*60
hour=minter*24)
func timesqr(seconds int)(secondout,minterout,hourout int) {
secondout=seconds
minterout=seconds/minter
hourout=seconds/hour
return
}
func main() {
fmt.Println(timesqr(1000))
//_,minterout,hourout=timesqr()
}
以上純?cè)谑謾C(jī)上敲,有點(diǎn)麻煩葵蒂。今天遇到的疑惑是GoLang的除法運(yùn)算不知道怎么算出小數(shù)點(diǎn)
1000/13得到的是整數(shù)交播,%8.3f也算不出來(lái),只是整數(shù)
明天再研究吧
--------------2019.2.14補(bǔ)錄---------------------
如果要出現(xiàn)小數(shù)點(diǎn)践付,則需要保證所有參與計(jì)算的變量都是flaot型
即func timesqr(seconds int)(secondout,minterout,hourout int) {
修改為func timesqr(seconds flaot)(secondout,minterout,hourout flaot) {