文章作者:炒香菇的书呆子 来源:CSDN

情人节又到了,今天为大家整理了几种画玫瑰线的代码,祝大家早日找到幸福的TA~

Python版本动态画玫瑰

import turtle

# 设置初始位置

turtle.penup()

turtle.left(90)

turtle.fd(200)

turtle.pendown()

turtle.right(90)

# 花蕊

turtle.fillcolor("red")

turtle.begin_fill()

turtle.circle(10, 180)

turtle.circle(25, 110)

turtle.left(50)

turtle.circle(60, 45)

turtle.circle(20, 170)

turtle.right(24)

turtle.fd(30)

turtle.left(10)

turtle.circle(30, 110)

turtle.fd(20)

turtle.left(40)

turtle.circle(90, 70)

turtle.circle(30, 150)

turtle.right(30)

turtle.fd(15)

turtle.circle(80, 90)

turtle.left(15)

turtle.fd(45)

turtle.right(165)

turtle.fd(20)

turtle.left(155)

turtle.circle(150, 80)

turtle.left(50)

turtle.circle(150, 90)

turtle.end_fill()

# 花瓣1

turtle.left(150)

turtle.circle(-90, 70)

turtle.left(20)

turtle.circle(75, 105)

turtle.setheading(60)

turtle.circle(80, 98)

turtle.circle(-90, 40)

# 花瓣2

turtle.left(180)

turtle.circle(90, 40)

turtle.circle(-80, 98)

turtle.setheading(-83)

# 叶子1

turtle.fd(30)

turtle.left(90)

turtle.fd(25)

turtle.left(45)

turtle.fillcolor("green")

turtle.begin_fill()

turtle.circle(-80, 90)

turtle.right(90)

turtle.circle(-80, 90)

turtle.end_fill()

turtle.right(135)

turtle.fd(60)

turtle.left(180)

turtle.fd(85)

turtle.left(90)

turtle.fd(80)

# 叶子2

turtle.right(90)

turtle.right(45)

turtle.fillcolor("green")

turtle.begin_fill()

turtle.circle(80, 90)

turtle.left(90)

turtle.circle(80, 90)

turtle.end_fill()

turtle.left(135)

turtle.fd(60)

turtle.left(180)

turtle.fd(60)

turtle.right(90)

turtle.circle(200, 60)

turtle.pendown()

turtle.done()

打开网易新闻 查看精彩图片

c语言画心形

#include

#include

int main()

//FILE *fp = fopen("graph.txt", "w+");

float x, y, f;

for(y = 1.6; y >= -1.6; y -= 0.15){

for(x = -1.1; x <= 1.1; x += 0.05){

f = x*x + pow(y - pow(x*x, 1.0/3), 2) - 1; //函数方程

//fputc(f <= 1E-5 ? '*' : ' ', fp);

putchar(f <= 1E-5 ? '*' : ' ');

//fputc('\n', fp);

putchar('\n');

for(y = 1.6; y >= -1.6; y -= 0.15){

for(x = -1.1; x <= 1.1; x += 0.05){

f = x*x + pow(y - pow(x*x, 1.0/3), 2) - 1; //函数方程

//fputc(f > 1E-5 ? '*' : ' ', fp);

putchar(f > 1E-5 ? '*' : ' ');

//fputc('\n', fp);

putchar('\n');

//fclose(fp);

return 0;

由于c没有图形界面,只有在控制台输出啦

打开网易新闻 查看精彩图片

matlab画3D玫瑰

function drawrose

grid on

[x,t]=meshgrid((0:24)./24,(0:0.5:575)./575.*20.*pi+4*pi);

p=(pi/2)*exp(-t./(8*pi));

change=sin(15*t)/150;

u=1-(1-mod(3.6*t,2*pi)./pi).^4./2+change;

y=2*(x.^2-x).^2.*sin(p);

r=u.*(x.*sin(p)+y.*cos(p));

h=u.*(x.*cos(p)-y.*sin(p));

map=[1.0000 0.6471 0.8275

0.9984 0.6353 0.8130

0.9969 0.6236 0.7985

0.9953 0.6118 0.7840

0.9937 0.6000 0.7695

0.9921 0.5882 0.7550

0.9906 0.5765 0.7404

0.9890 0.5647 0.7259

0.9874 0.5529 0.7114

0.9859 0.5412 0.6969

0.9843 0.5294 0.6824

0.9757 0.5149 0.6730

0.9670 0.5004 0.6636

0.9584 0.4859 0.6541

0.9498 0.4714 0.6447

0.9411 0.4568 0.6353

0.9325 0.4423 0.6259

0.9239 0.4278 0.6165

0.9153 0.4133 0.6070

0.9066 0.3988 0.5976

0.8980 0.3843 0.5882

0.8937 0.3780 0.5756

0.8894 0.3718 0.5631

0.8851 0.3655 0.5505

0.8808 0.3592 0.5380

0.8764 0.3529 0.5254

0.8721 0.3467 0.5129

0.8678 0.3404 0.5003

0.8635 0.3341 0.4878

0.8592 0.3279 0.4752

0.8549 0.3216 0.4627

0.8561 0.3165 0.4596

0.8573 0.3114 0.4564

0.8584 0.3063 0.4533

0.8596 0.3012 0.4502

0.8608 0.2961 0.4471

0.8620 0.2910 0.4439

0.8632 0.2859 0.4408

0.8643 0.2808 0.4377

0.8655 0.2757 0.4345

0.8667 0.2706 0.4314

0.8549 0.2620 0.4165

0.8432 0.2533 0.4016

0.8314 0.2447 0.3867

0.8196 0.2361 0.3718

0.8078 0.2274 0.3569

0.7961 0.2188 0.3420

0.7843 0.2102 0.3271

0.7725 0.2016 0.3122

0.7608 0.1929 0.2973

0.7490 0.1843 0.2824

0.7553 0.1827 0.2855

0.7616 0.1812 0.2887

0.7678 0.1796 0.2918

0.7741 0.1780 0.2949

0.7804 0.1764 0.2980

0.7867 0.1749 0.3012

0.7930 0.1733 0.3043

0.7992 0.1717 0.3074

0.8055 0.1702 0.3106

0.8118 0.1686 0.3137

0.7977 0.1631 0.3023

0.7836 0.1576 0.2910

0.7694 0.1521 0.2796

0.7553 0.1466 0.2682

0.7412 0.1411 0.2569

0.7271 0.1357 0.2455

0.7130 0.1302 0.2341

0.6988 0.1247 0.2227

0.6847 0.1192 0.2114

0.6706 0.1137 0.2000

0.6686 0.1141 0.1996

0.6667 0.1145 0.1992

0.6647 0.1149 0.1988

0.6628 0.1153 0.1984

0.6608 0.1157 0.1981

0.6588 0.1160 0.1977

0.6569 0.1164 0.1973

0.6549 0.1168 0.1969

0.6530 0.1172 0.1965

0.6510 0.1176 0.1961];

set(gca,'CameraPosition',[2 2 2])

hold on

surface(r.*cos(t),r.*sin(t),h,'EdgeAlpha',0.1,...

'EdgeColor',[0 0 0],'FaceColor','interp')

colormap(map)

end

打开网易新闻 查看精彩图片

Java画玫瑰线

import java.awt.Canvas;

import java.awt.Color;

import java.awt.Dimension;

import java.awt.Graphics;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.*;

public class RoseJFrame extends JFrame implements ActionListener {

private RoseCanvas canvas;

public RoseJFrame() {

super("四叶玫瑰线");

Dimension dim = getToolkit().getScreenSize();

this.setBounds(dim.width/4, dim.height/4, dim.width/2, dim.height/2);

this.setDefaultCloseOperation(EXIT_ON_CLOSE);

JPanel jpanel = new JPanel();

this.getContentPane().add(jpanel, "North");

JButton button_color = new JButton("选择颜色");

jpanel.add(button_color);

button_color.addActionListener(this);

this.canvas = new RoseCanvas(Color.red);

this.getContentPane().add(this.canvas, "Center");

this.setVisible(true);

@Override

public void actionPerformed(ActionEvent e) {

Color c = JColorChooser.showDialog(this, "选择颜色", Color.blue);

this.canvas.setColor(c);

this.canvas.repaint();

public static void main(String args[])

new RoseJFrame();

class RoseCanvas extends Canvas {

private Color color;

public RoseCanvas(Color color) {

this.setColor(color);

public void setColor(Color color) {

this.color = color;

public void paint(Graphics g) {

int x0 = this.getWidth() / 2;

int y0 = this.getHeight() / 2;

g.setColor(this.color);

g.drawLine(x0, 0, x0, y0 * 2);

g.drawLine(0, y0, x0*2, y0);

for (int j = 40; j < 100; j += 20)

for (int i = 0; i < 1024; i++) {

double angle = i*Math.PI/512;

double radius = j*Math.sin(8*angle);

int x = (int)Math.round(radius * Math.cos(angle) * 2);

int y = (int)Math.round(radius * Math.sin(angle));

g.fillOval(x0 + x, y0 + y*2, 2, 2);

打开网易新闻 查看精彩图片

HTML动态玫瑰

flower

A beautiful flower for the most beautiful person under the sun

LOVE

打开网易新闻 查看精彩图片

以上内容阅读完毕,推荐大家参加由中国亚洲经济发展协会职业人才开发与管理委员会指导主办的“2024年大学生AI数字能力系列赛”!以赛辅练,提升专业能力!

打开网易新闻 查看精彩图片

人工智能是当今世界最具变革力和影响力的技术之一,预计到2025年,人工智能市场规模将超过1000亿美元。为积极响应国家“科教兴国,人才强国”战略、培养具有综合技能的数字型人才、推动教育数字化升级,在中国亚洲经济发展协会职业人才开发与管理委员会的指导下,北京综合赋能科学技术中心特举办“2024年全国大学生AI数字能力系列竞赛”。

竞赛官网

打开网易新闻 查看精彩图片

组织单位

主办单位:北京综合赋能科学技术中心

打开网易新闻 查看精彩图片

中国产业赋能协作平台在中国亚洲经济发展协会、中国生产力促进中心协会、中国工业报社等单位倡议下,联合中国科学技术协会下属的中翰国智公司、北大博雅财经智库等单位共同发起,作为链接政府、企业的创新型产业赋能、加速平台,服务地方产业集群建设,助力企业高质量发展。

指导单位:中国亚洲经济发展协会职业人才开发与管理委员会

中国亚洲经济发展协会(以下简称“协会”)是由中华人民共和国外交部指导成立、民政部登记的全国性社会组织,为国家一级协会。职业人才开发与管理委员会为其下属委员会。

参赛对象

普通高等院校、高职院校、二级学院、独立学院、本、专科在校大学生及研究生均可报名参加,专业不限

竞赛赛项

本次大赛分别设置:办公软件赛道科普赛道编程赛道实操赛道。各赛道比赛方式、竞赛内容均有不同。

赛道分类:

办公软件赛道主要考察AI运用的能力,考试内容为通过训练AI,生成题目中的Word、PPT、Excel及图片。

科普赛道主要考察人工智能相关科普知识,考试形式为客观题答题。

编程赛道主要考察AI训练及基础编程语言的能力,包括C/C++、Python两种语言,考试形式为实操题。

实操赛道主要考察学生对于Windows系统及手机相关操作的能力,考试形式为客观题答题。

赛程安排

办公软件赛道赛程安排

报名时间:2024年2月4日—2024年4月5日

竞赛时间:2024年4月6日10:00—4月12日18:00

科普赛道赛程安排

报名时间:2024年2月4日—2024年4月26日

竞赛时间:2024年4月27日9:00—18:00

编程赛道赛程安排

报名时间:2024年2月4日—2024年4月30日

竞赛时间:2024年5月1日10:00—2024年5月11日18:00

实操赛道赛程安排

报名时间:2024年2月4日—2024年5月24日

竞赛时间:2024年5月25日9:00—18:00

奖项设置

学生奖项

(1)科普赛道、实操赛道竞赛奖项:

一等奖:竞赛成绩在90—100分;

二等奖:竞赛成绩在80—89分;

三等奖:竞赛成绩在70—79分;

优秀奖:竞赛成绩在60—69分。

(2)办公软件赛道、编程赛道竞赛奖项:

一等奖:不超过报名人的5%;

二等奖:不超过报名人数的15%;

三等奖:不超过报名人数的30%;

优秀奖:若干。

获得一、二、三等奖以及优秀奖均可获得获电子版和纸质版证书,其余未获奖但按要求参赛,遵守大赛规则,认真完成赛题均可获得电子版参赛证明,以兹鼓励。

教师奖项

1.该赛事采取师生同奖原则,凡获得一、二、三等奖选手所填写的指导老师均可获得“优秀指导教师”电子版荣誉证书(一位学生最多填写一位老师)。

2.对本次赛事有宣传组织贡献,组织、指导10人及以上学生成功参与竞赛的老师,可获得“优秀指导教师”电子版和纸质版荣誉证书

集体奖项

在学校范围内组织学生报名,参与赛事宣传组织工作,指导学生参赛,所有指导老师均可获得“优秀指导教师”纸质版证书,参与人数多时可获得“优秀组织单位”牌匾。

联系方式

负责人QQ:442390726(苏老师)

竞赛交流群:784713647

BONUS TIME

数学建模资料、视频讲解、历年赛题

后台回复 【校苑】领取

打开网易新闻 查看精彩图片

推荐阅读(点击下方图片即可跳转)

打开网易新闻 查看精彩图片