[英]Repeat Number Sequence in C
Can you help me fix my code?你能帮我修复我的代码吗?
Sample Input:样本输入:
8 4
8 4
Sample Output:样品 Output:
1 2 3 4 1 2 3 4
1 2 3 4 1 2 3 4
Explanation:解释:
8 is the limit of sequence numbers 8是序列号的限制
4 is the maximum number that starts from 1 4是从1开始的最大数
I can only write我只能写
for (i = 1; i <= limit_number; i++)
to make an output: 1 2 3 4 5 6 7 8制作 output:1 2 3 4 5 6 7 8
What else do I need?我还需要什么?
Try this:尝试这个:
int maximum = 4, limit_number = 8;
for(i = 0; i<limit_number; i++)
printf("%d ", (i%maximum) + 1);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.