#include <stdio.h>
#define SIZE 9
int main() { int arr[SIZE]; int num = 123456789; // our example int div = 10; // divisor int i, k=1; // k - detect right box of array
// form number == 123 to array == 123 for (i=0; i < SIZE; i++) { arr[SIZE-k] = (num%div)/(div/10); div *= 10; k++; }
printf("\nArray in standart view: "); for(i = 0; i < SIZE; i++) { printf("%d", arr[i]); } printf("\n");
// form number == 123 to array == 321 div = 10;
for (i=0; i < SIZE; i++) { arr[i] = (num%div)/(div/10); div *= 10; }
printf("Array in reverse view: "); for(i = 0; i < SIZE; i++) { printf("%d", arr[i]); }
printf("\n\n"); return 0; } |