Can you help me fix my code?
Sample Input:
8 4
Sample Output:
1 2 3 4 1 2 3 4
Explanation:
8 is the limit of sequence numbers
4 is the maximum number that starts from 1
I can only write
for (i = 1; i <= limit_number; i++)
to make an 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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.