mfgnik

Untitled

Jan 25th, 2021
777
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include <math.h>
  4. #define N 100
  5.  
  6. void swap(double a[N], int n) {
  7.     int i =0;
  8.     for (i = 0; i < n; i += 2){
  9.         double tmp = a[i];
  10.         a[i] = a[i + 1];
  11.         a[i + 1] = tmp;
  12.     }
  13.  
  14.     for (i = 0; i < n; i++){
  15.     printf("lg", a[i]);
  16.     }
  17. }
  18.  
  19. int main(){
  20.     double a[N];
  21.     int n, i;
  22.     printf("Input the size of the massiv: ");
  23.     scanf("%d", &n);
  24.     for (i = 0; i < n; i++) {
  25.         printf("a[%d] = ", i);
  26.         scanf("%lg", &a[i]);
  27.     }
  28.     swap(a, n);
  29. }
RAW Paste Data