每日codingame小游戏练习[2021.4.21](python3入门学习之生成三角形)

题目描述

无文字描述,看实例写代码
eg1:

InputOutput
11

eg2:

InputOutput
22
22

eg3:

InputOutput
33
33
333

eg3:

InputOutput
33
33
333<>

eg4:

InputOutput
44
44
444
4444

eg5:

InputOutput
55
55
555
5555
55555

题目分析

题目要求我们生成一个三角形。

解题代码

想了半天,我最终还是没有写出来,下面是瑞典老哥的代码:

import sys
import math

# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.

n = int(input())

for i in range(1,n+1):
    print(str(n)*i)

印度阿三的代码:

import sys
import math

# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.

n = int(input())

# Write an answer using print
# To debug: print("Debug messages...", file=sys.stderr, flush=True)

for i in range(1,n+1):
    for j in range(i):
        print(n,end='')
    print()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值