Untitled
unknown
c_cpp
2 years ago
816 B
11
Indexable
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <time.h>
int main()
{
srand(time(NULL));
SetConsoleCP( 1251 );
SetConsoleOutputCP( 1251 );
int size;
scanf("%d", &size);
int* arr = (int*)malloc(size * sizeof(int));
if (arr == NULL){// успешность выполнения памяти
puts ("Ошибка выделенимя памяти");
return 1;
}
int i;
for (i = 0; i < size; i++){
arr[i] = rand() % 101 - 50;
printf("%4d", arr[i]);
}
int first = arr[0];
for (i = 0; i < size - 1; ++i )
arr[i] = arr[i + 1];
arr[size - 1] = first;
puts("");
for (i = 0; i < size; ++i)
printf("%2d ", arr[i]);
free(arr);
return 0;
}
Editor is loading...
Leave a Comment