Advertisement
Archangelpl

Untitled

May 21st, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 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. for (int i = 1; i < n + 1; i++)
  24. {
  25. printf("%lf ", d[i]);
  26. }
  27. }
  28. int main()
  29. {
  30. double *d;
  31. int n;
  32.  
  33. if (!(fd = fopen("dane.txt", "r")))
  34. {
  35. printf("Blad wczytywania danych");
  36. exit(0);
  37. }
  38. fscanf(fd, "%d", &n);
  39. d = malloc(n * sizeof(double));
  40. printf("Tablica: \n");
  41. for (int i = 0; i < n;i++)
  42. {
  43.  
  44. fscanf(fd, "%lf", &d[i]);
  45. printf("%lf ", d[i]);
  46.  
  47. }
  48. printf("\n Odwr: \n");
  49.  
  50.  
  51. srA(d, n);
  52.  
  53.  
  54. printf("\n");
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement