用for嵌套循环产生图案
使用嵌套循环产生下列图案,要求用for嵌套循环(感谢感谢)F
_FE
__FED
___FEDC
____FEDCB
_____FEDCBA 本帖最后由 jackz007 于 2021-12-6 00:18 编辑
for i in range(1 , 7):
s = '_' * (i - 1) + '' . join(chr(ord('F') - k) for k in range(i))
print(s)
运行实况:
D:\00.Excise\Python>python x.py
F
_FE
__FED
___FEDC
____FEDCB
_____FEDCBA
D:\00.Excise\Python>
for(i=0;i<6;i++)
{
for(j=0;j<i;j++)printf("_");
for(j=0;j<=i;j++)printf("%c",'F'-j);
}
页:
[1]