42 lines
768 B
C
42 lines
768 B
C
|
#include<stdio.h>
|
||
|
#include<stdlib.h>
|
||
|
#include<time.h>
|
||
|
|
||
|
#define DECALAGE 4
|
||
|
|
||
|
void showtable(int tablesize, int* table) {
|
||
|
for (int i = 0; i < tablesize; i++) printf("+-----");
|
||
|
printf("+\n");
|
||
|
|
||
|
for (int i = 0; i < tablesize; i++) printf("| %3d ", table[i]);
|
||
|
printf("|\n");
|
||
|
|
||
|
for (int i = 0; i < tablesize; i++) printf("+-----");
|
||
|
printf("+\n");
|
||
|
}
|
||
|
|
||
|
int main(int argc, char * argv[]) {
|
||
|
int tab[10] = {};
|
||
|
|
||
|
srand(time(NULL));
|
||
|
int rand_v = rand();
|
||
|
|
||
|
for (int i = 0; i < 10; i++) {
|
||
|
srand(rand_v);
|
||
|
tab[i] = rand() % 101 > 50 ? (-rand() % 100) + 50: (rand() % 100) - 50;
|
||
|
rand_v = rand();
|
||
|
}
|
||
|
|
||
|
showtable(10, tab);
|
||
|
|
||
|
int tab2[10] = {};
|
||
|
for (int i = 0; i < 10; i++) {
|
||
|
int i2 = (i+DECALAGE) % 10;
|
||
|
tab2[i2] = tab[i];
|
||
|
}
|
||
|
|
||
|
showtable(10, tab2);
|
||
|
return EXIT_SUCCESS;
|
||
|
}
|
||
|
|