DEV Community

Leo
Leo

Posted on

Queue

#include <iostream>

int forth(int i, int n){

  return (i + 1) % n;
  //return i % n + 1  // indexado a partir de 0
}

int main() {

  int n = 7;
  int i = 3;

  for (int k = 0; k < 100; k++) {

    std::cout << i << std::endl;
    i = forth(i, n);
  }

  return 0;
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)