fork download
  1. #include <stdio.h>
  2.  
  3. #define GET_KTH(list, n, k) ((list)[(k) % (n)])
  4. #define LIST_LEN(list) (sizeof((list)) / sizeof((list)[0]))
  5.  
  6. int main() {
  7. int list[] = {1, 2, 3};
  8. for (size_t i = 0; i < 55; ++i) {
  9. printf("%d\r\n", GET_KTH(list, LIST_LEN(list), i));
  10. }
  11. return 0;
  12. }
  13.  
Success #stdin #stdout 0s 5292KB
stdin
Standard input is empty
stdout
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1