Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void reverse(int mas[], int N); // Переворот массива
- void print(int mas[], int N); // Вывод массива на экран
- int main(){
- unsigned const int SIZE = 10; // Размер массива
- int a[SIZE]; // Массив
- // Заполнение массива
- int i;
- for(i=0; i < SIZE; i++)
- a[i]=3*i-2;
- // Печать изначального массива
- print(a, SIZE);
- // Переворот массива
- reverse(a, SIZE);
- // Печать измененного массива
- print(a, SIZE);
- return 0;
- }
- void reverse(int mas[], int N){
- int i, j;
- for(i = 0, j = N-1; i < j; i++,j--){
- int temp = mas[i];
- mas[i] = mas[j];
- mas[j] = temp;
- }
- }
- void print(int mas[], int N){
- int i;
- for(i = 0; i < N; i++)
- printf("%d ", mas[i]);
- printf("\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement