leetcode--笔记8 Fizz Buzz
2024-10-19 02:48:01
题目要求:
Write a program that outputs the string representation of numbers from 1 to n.
But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”.
my answer:
测试错误分析:
1 range(n)的使用,记住range(2)代表0,1 是从0开始的,所以上述遍历之后的 i 要变为 i+1
2 s%3==0 , 对于小于3的数也是成立的,所以这里分开讨论了
3 首先if 同时整除3和5的数,否则会出错
4 如果 output.append(“u”),直接加双引号会出错,输出"u" ,而不输出遍历的数字,所以需要用函数 str( )
最新文章
- 【项目管理】图解GitHub基本操作
- Linux Shell 流程控制语句
- JSBinding+Bridge.NET限制
- codeforces #270 ABCD
- SQL 游标使用实例
- Node快速安装
- sqlserver函数
- nedb nodejs 数据库学习
- pxecfg&;kickstart生成脚本
- 快速同步mysql数据到redis中
- java-finalize
- Javascript和JQuery中常用的随机数产生函数
- 设置和取消git代理
- SHELL脚本--shell数组基础
- 省选前的JOI
- How to use Jackson to deserialise an array of objects
- vue(ajax:axios中文文档)
- OpenStack 图形化服务 Horizon介绍和部署(十二)
- Decorator - 装饰模式
- ios 解决Wkwebview闪烁问题