Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <malloc.h>
  3. #include <math.h>
  4.  
  5. const int Mx = 1005;
  6. int n;
  7. float dt, arr[1005];
  8.  
  9. int main()
  10. {
  11. FILE *fr = fopen("input.txt", "r");
  12. FILE *fw = fopen("output.txt", "w");
  13. if (fr == NULL)
  14. {
  15. fprintf (fw, "Invalid input");
  16. }
  17.  
  18. fread (arr, sizeof(float), n, fr);
  19. if (n < 0 || n >= 1000 || dt <= 0 || dt >= 0.1)
  20. {
  21. fprintf (fw, "Invalid input");
  22. }
  23. else
  24. {
  25. float *arr = malloc(sizeof(float)*n);
  26. for (int i = 0; i < n; i++) {
  27. arr[i] = sinf(i * dt);
  28. }
  29. for (int i = n - 1; i >= 0; i--) {
  30. fprintf (fw, "%.4f", arr[i]);
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement