Advertisement
Archangelpl

Untitled

May 21st, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. // ConsoleApplication5.cpp: Określa punkt wejścia dla aplikacji konsoli.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <stdlib.h>
  6. #include<stdio.h>
  7. #include <math.h>
  8.  
  9. FILE *fd;
  10.  
  11. double srA(double *d, int n)
  12. {
  13. double tmp;
  14.  
  15.  
  16. int z = 0, k = 0;
  17. for (int i =n; i > n/2;i--)
  18. {
  19. tmp = d[i];
  20. d[i] = d[i - 1];
  21. d[n - i] = tmp;
  22. }
  23. return d[n];
  24. }
  25. int main()
  26. {
  27. double *d;
  28. int n;
  29.  
  30. if (!(fd = fopen("dane.txt", "r")))
  31. {
  32. printf("Blad wczytywania danych");
  33. exit(0);
  34. }
  35. fscanf(fd, "%d", &n);
  36. d = malloc(n * sizeof(double));
  37. for (int i = 0; i < n;i++)
  38. {
  39.  
  40. fscanf(fd, "%lf", &d[i]);
  41. printf("%lf ", d[i]);
  42.  
  43. }
  44. printf("\n");
  45.  
  46. for (int i = 0; i < n;i++)
  47. {
  48. printf("%lf ", srA(d, n));
  49. }
  50. printf("\n");
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement