第2周项目2就拿胖子说事

#include<iostream>
using namespace std;
int main()
{
	int biaozhun,heigh,weight;
	cin>>heigh>>weight;
	biaozhun=heigh-100;
	cout<<biaozhun<<endl;
	if(biaozhun*1.2<weight)
    cout<<"超重"<<endl;
	else if(biaozhun*0.8>weight)
		cout<<"超轻"<<endl;
	else
		cout<<"正常"<<endl;
	return 0;
}

运行结果:


知识点总结:

  从这个程序中,进一步了解c++的基本程序构造,更加熟练运用c++。

学习心得:

 避免范一些漏掉分号的小错误。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个使用Python的turtle模块绘制小猪并在脸上写字的示例代码: ```python import turtle # 绘制小猪的函数 def draw_pig(): # 设置画笔颜色和粗细 turtle.pensize(3) turtle.pencolor('pink') turtle.fillcolor('pink') # 绘制头部 turtle.begin_fill() turtle.circle(50) turtle.end_fill() # 绘制耳朵 turtle.penup() turtle.goto(-30, 80) turtle.pendown() turtle.begin_fill() turtle.circle(20) turtle.end_fill() turtle.penup() turtle.goto(30, 80) turtle.pendown() turtle.begin_fill() turtle.circle(20) turtle.end_fill() # 绘制眼睛 turtle.penup() turtle.goto(-20, 20) turtle.pendown() turtle.fillcolor('black') turtle.begin_fill() turtle.circle(5) turtle.end_fill() turtle.penup() turtle.goto(20, 20) turtle.pendown() turtle.begin_fill() turtle.circle(5) turtle.end_fill() # 绘制鼻子 turtle.penup() turtle.goto(0, 0) turtle.pendown() turtle.begin_fill() turtle.circle(10) turtle.end_fill() # 绘制嘴巴 turtle.penup() turtle.goto(0, -20) turtle.pendown() turtle.pencolor('red') turtle.right(90) turtle.circle(20, 180) # 在猪的脸上写字 turtle.penup() turtle.goto(0, 50) turtle.pendown() turtle.pencolor('black') turtle.write('逸娇是小胖子', align='center', font=('Arial', 16, 'normal')) # 初始化画布和画笔 turtle.setup(400, 400) turtle.penup() turtle.goto(0, -100) turtle.pendown() # 调用绘制小猪的函数 draw_pig() # 点击关闭窗口 turtle.exitonclick() ``` 运行以上代码后,会在窗口中绘制一只可爱的小猪,并在猪的脸上写上了“逸娇是小胖子”这句话。你可以根据需要修改代码中的颜色、大小、字体等参数来调整小猪的样子和文本的样式。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值