首頁>技術>

過年了,送一顆真心給您,新的一年,心開目明,心曠神恬,真心誠意,心心相應,心想事成。

python一行程式碼畫心
print('\n'.join([''.join([('Love'[(x-y) % len('Love')] if ((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3 <= 0 else ' ') for x in range(-30, 30)]) for y in range(30, -30, -1)]))

python

golang畫心
package mainimport (	"flag"	"fmt"	"math"	"strings"	"time")func main() {	var head string	var tail string	var MYWORD string	var sep string	var zoom float64	flag.StringVar(&head, "head", "There are some words I wana tell you:", "A sentence printed on the head")	flag.StringVar(&tail, "tail", "\t\t\t\t--- Your lover", "A sentence printed on the tail")	flag.StringVar(&MYWORD, "words", "Dear, I love you forever!", "The words you want to talk")	flag.StringVar(&sep, "sep", " ", "The separator")	flag.Float64Var(&zoom, "zoom", 1.0, "Zoom setting")	flag.Parse()	chars := strings.Split(MYWORD, sep)	time.Sleep(time.Duration(1) * time.Second)	fmt.Println(head)	fmt.Println()	time.Sleep(time.Duration(1) * time.Second)	for _, char := range chars {		allChar := make([]string, 0)		for y := 12 * zoom; y > -12*zoom; y-- {			lst := make([]string, 0)			lstCon := ""			for x := -30 * zoom; x < 30*zoom; x++ {				x2 := float64(x)				y2 := float64(y)				formula := math.Pow(math.Pow(x2*0.04/zoom, 2)+math.Pow(y2*0.1/zoom, 2)-1, 3) - math.Pow(x2*0.04/zoom, 2)*math.Pow(y2*0.1/zoom, 3)				if formula <= 0 {					index := int(x) % len(char)					if index >= 0 {						lstCon += string(char[index])					} else {						lstCon += string(char[int(float64(len(char))-math.Abs(float64(index)))])					}				} else {					lstCon += " "				}			}			lst = append(lst, lstCon)			allChar = append(allChar, lst...)		}		for _, text := range allChar {			fmt.Printf("%s\n", text)		}	}	time.Sleep(time.Duration(1) * time.Second)	fmt.Println("\t\t\t\t", tail)}

golang

golang

shell畫心
#!/bin/bashy=1250for (( yy = 45; yy > 0; yy-- )); dox=-1140	for (( xx = -120; xx < 0; xx++ )); do		ff=$(echo `awk -v x=${x} -v y=${y} 'BEGIN{printf "%.0f\n",(((x/1000)*(x/1000)+(y/1000)*(y/1000)-1)*((x/1000)*(x/1000)+(y/1000)*(y/1000)-1)*((x/1000)*(x/1000)+(y/1000)*(y/1000)-1)-(x/1000)*(x/1000)*(y/1000)*(y/1000)*(y/1000))*10000000}'`)		if [[ ff -le 0 ]]; then			printf "\e[1;41m \e[0m"		else		    printf " "		fi	x=$((${x}+20))	doneprintf "\n"y=$((${y}-50))done

shell

c畫心
#include <stdio.h>int main() {    for (float y = 1.5f; y > -1.5f; y -= 0.1f) {        for (float x = -1.5f; x < 1.5f; x += 0.05f) {            float a = x * x + y * y - 1;            putchar(a * a * a - x * x * y * y * y <= 0.0f ? '*' : ' ');        }        putchar('\n');    }}

c

參考彙集

https://blog.csdn.net/bigzql/article/details/109713022

https://blog.csdn.net/u014692474/article/details/102485519

https://studygolang.com/articles/26272?fr=sidebar

https://blog.csdn.net/freesonWANG/article/details/101040746

12
最新評論
  • BSA-TRITC(10mg/ml) TRITC-BSA 牛血清白蛋白改性標記羅丹明
  • 使用jekyll寫Github-Pages