Last active
August 29, 2015 14:21
-
-
Save nesffer/f5acccc03aa46572b1ea to your computer and use it in GitHub Desktop.
Array Element Move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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