通过while循环一步步实现九九乘法表
# 打印#做出@列的效果
height = int(input("height: ")) #用户输入一个高度
num_height = height
while num_height > 0:
print("@")
num_height -= 1
# 打印#做出@列的效果
width = int(input("width: ")) #用户输入一个宽度
num_width = 1 #第一步 赋值
while num_width <= width: #第二步 num_width == 1
print("#",end="") #第三步 不换行 打印一个#
num_width += 1 #第四步 num_width == 2
print()
# 打印#做出N行X列的效果
height = int(input("height: ")) #用户输入一个高度
width = int(input("width: ")) #用户输入一个宽度
num_height = 1
while num_height <= height:
num_width = 1
while num_width <= width:
print("#",end="")
num_width += 1
print()
num_height += 1
通过前面的铺垫,现在开始尝试打印九九乘法表
#九九乘法表
first = 1
while first <=9:
second = 1
while second <= first:
print(str(second)+"*"+str(first)+"="+str(second*first),end="\t")
second +=1
first +=1
print()
通过while循环一步步实现九九乘法表的更多相关文章
- 编写Java程序,使用循环结构打印出九九乘法表
编写Java程序,使用循环结构打印出九九乘法表 效果如下: 实现代码: public class Multiplication99 { public static void main(String[] ...
- python—用for循环、while循环和一句话打印九九乘法表
用for循环打印九九乘法表: for i in range (1,10): for j in range(1,10): print(j,"x",i,"=",i* ...
- Oracle三种循环例题:打印九九乘法表
数据库SQL三种循环语句(For.While.Loop) --如果要将执行结果输出,需要先执行 setserveroutput on 命令,在窗口里显示服务器输出信息 set serveroutput ...
- For 循环的嵌套与九九乘法表
㈠通过程序,在页面中输入如下图形 * * * * * * * * * * * * * * * * * * * * * * * * * 代码如下: //向body中输入一个内容 //document. ...
- C语言for 循环 9*9 实现九九乘法表
#include <stdio.h> int main(void) { //for循环实现9*9乘法表 /* 1*1=1 1*2=2 2*2=4 1*3=3 2*3=6 3*3=9 */ ...
- 利用js的for循环实现一个简单的“九九乘法表”
For循环九九乘法表 for循环是javascript中一种常用的循环语句,可以很好的解决在程序中需要重复执行某些语句,利用for循环实现简单的“九九乘法表”的效果: 让循环从小到大,依次排序,并计算 ...
- Python中的九九乘法表(for循环)
用for循环写出的九九乘法表(包括函数的调用) #方向一 for i in range(1,10): for j in range(1,i+1): d = i * j ...
- 用for; while...do; do...while; 写出九九乘法表
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 【Java】Java_15 打印九九乘法表
使用For循环嵌套即可打印九九乘法表 以下是具体代码: /** * 打印九九乘法表 */ package com.oliver.test; public class TestMultiplicatio ...
随机推荐
- Day2-G-Sticks-POJ1011
George took sticks of the same length and cut them randomly until all parts became at most 50 units ...
- nodejs(12)Express 中间件middleware
中间件 客户端的请求到达服务器时,他的生命周期是:request -- 服务器端处理 -- 响应 在服务器端处理过程中,业务逻辑复杂时,为了便于开发维护,需要把处理的事情分成几步,这里每一步就是一个中 ...
- 前端学习笔记系列一:13new Date()的参数
前两天发现手机页面的倒计时在Android上正常显示,在iPhone却不能显示. 后来又发现在ff和ie里也不显示.(以前只在chrome里看过,显示正常). 后来同事改了new Date()里字符串 ...
- php面向对象的三大特性——封装、继承、多态
1.封装 目的:为了使类更加安全,类里面的成员变量对外界隐藏 做法: 1)将成员变量变成私有的: 2)在类中做方法间接访问成员变量: 3)在方法里面加控制条件. 例: class ren{ priva ...
- 算法:辗转相除法求最大公约数(C语言实现)
辗转相除法,一种求最大公约数的算法 已知:A / B = C ······ R (A.B.C.R皆是整数) 假设:D是A的余数,D也是B的余数,那么D就是A和B的公约数 D是A和B的约数,则A和B是 ...
- Xilinx COE文件格式小记
官方的参考文档是:https://www.xilinx.com/support/documentation/sw_manuals/xilinx11/cgn_r_coe_file_syntax.htm ...
- jenkins#安装docker
环境:centos7 安装依赖包 yum install -y yum-utils device-mapper-persistent-data lvm2 添加Docker软件包源 yum-config ...
- android名词
NDK:Native Development Kit JNI:Java Native Interface
- java api 远程连接 hdfs
IDEA中新建Maven工程,添加POM依赖, 在IDE的提示中, 点击 Import Changes 等待自动下载完成相关的依赖包. <?xml version="1.0" ...
- SQL添加列、非空、默认值
use MarcoBarcode go alter table [dbo].[WorkOrderRepairSheet] ADD needRepair int go ALTER TABLE [dbo] ...