Skip to content

Instantly share code, notes, and snippets.

@ghost355
Last active November 17, 2024 16:02
Show Gist options
  • Save ghost355/0acea1be7a92d2ecbdb87470bd1dab4b to your computer and use it in GitHub Desktop.
Save ghost355/0acea1be7a92d2ecbdb87470bd1dab4b to your computer and use it in GitHub Desktop.
Loop number цикличный перебор 1..n..1
#include <stdio.h>
#include <stdlib.h>
#define MAX_VALUE 5
//x16 -> 1,2,3,4,5,4,2,1,2,3,4,5,4,3...
int main() {
for (int n = 0; n < 16; ++n) { // измените количество шагов, если нужно
int x = MAX_VALUE - abs(MAX_VALUE - (n % (2 * (MAX_VALUE - 1))));
printf("%d\n", x);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment