Skip to content

Instantly share code, notes, and snippets.

@nesffer
Last active August 29, 2015 14:21
Show Gist options
  • Save nesffer/f5acccc03aa46572b1ea to your computer and use it in GitHub Desktop.
Save nesffer/f5acccc03aa46572b1ea to your computer and use it in GitHub Desktop.
Array Element Move
#include <stdio.h>
#define RANGE 10
int main() {
int kk[RANGE] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int i, j, move, temp;
printf("몇 번 이동 시키겠습니까? ");
scanf_s("%d", &move);
printf("\n");
printf("Before: ");
for (i = 0; i < 10; i++) {
printf("%d ", kk[i]);
}
printf("\n");
for (i = 0; i < move; i++) {
temp = kk[RANGE - 1];
for (j = RANGE - 2; j >= 0; j--) {
kk[j + 1] = kk[j];
}
kk[0] = temp;
}
printf("After: ");
for (i = 0; i < 10; i++) {
printf("%d ", kk[i]);
}
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment