互联网技术 / 互联网资讯 · 2023年12月26日

云计算开发:Python练习实例-整数向后移动m个位置

有 n 个整数,使其前面各数顺序向后移 M 个位置,最后 M 个数变成最前面的 M 个数。

1.这n个数是由用户输入的,M也是用户输入的;

2.这n个数装到数组里面应该会好处理些;

3.新建一个长度跟原数组一样的数组;

4.遍历两个数组,对应M值进行数据转移。

云计算开发:Python练习实例-实现有n个整数,使其前面各数向后移m个位置

云计算开发:Python练习实例-实现有n个整数,使其前面各数向后移m个位置

OpenMagic API

Need more than content? Move into the product flow.

If you are here for model access, pricing, developer docs, or the future API console, the dedicated product path now lives on api.openmagic.ai.

登录免费注册