计算一个数的平方的方法

package main

import (
	"fmt"
)

func main() {
	var b float64
	var a float64 = 42
	b = a * a
	fmt.Println("结果", b)
}

  

package main

import (
	"fmt"
	"math"
)

func main() {
	var b float64
	var a float64 = 42
	b = math.Pow(a, 2)
	fmt.Println("结果", b)
}

  

package main

import "fmt"

func main() {
	var name string
	var age int
	fmt.Print("请输入您的姓名")
	fmt.Scanln(&name)
	fmt.Println("请输入您的年龄")
	fmt.Scanln(&age)
	fmt.Println("姓名%s,年龄%d\n", name, age)
}

  

package main

import "fmt"

func main() {
	a, b := 7, 9
	if a > b {
		fmt.Println("大于")
	} else {
		fmt.Println("小于")
	}
}

  

package main

import "fmt"

func main() {
	for i := 0; i < 100; i++ {
		fmt.Println(i)
	}
}

  

package main

import "fmt"

func main() {
	i := 1
	for i < 10 {
		i++
		fmt.Println(i)
	}
}

  

package main

import "fmt"

func main() {
	for i := 0; i < 9; i++ {
		for j := 0; j < 9; j++ {
			if i == 5 {
				fmt.Printf("%d x %d =%d\t", i, j, i*j)
				continue
			} else if i > 5 {
				break
			}
		}
	}
}

  

posted @ 2024-12-20 11:47  飞雪飘鸿  阅读(2)  评论(0编辑  收藏  举报
https://damo.alibaba.com/ https://tianchi.aliyun.com/course?spm=5176.21206777.J_3941670930.5.87dc17c9BZNvLL