Advertisement
Lustacho

Untitled

Oct 14th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "stdio.h"
  3. #include "windows.h"
  4. #include "locale.h"
  5. #include "math.h"
  6. #define MAX_N 1000
  7.  
  8. int _tmain(int argc, _TCHAR* argv[])
  9. {
  10. setlocale(LC_ALL, "rus");
  11. system("color F0");
  12. int n;
  13. printf ("введите количество элементов массива\n");
  14. do
  15. {
  16. scanf("%d",&n);
  17. }
  18. while (n<=0 || n>MAX_N);
  19. int arr[MAX_N];
  20. int i;
  21. for (i=0; i<n; i++)
  22. {
  23. printf("x[%d]=",i+1);
  24. scanf( "%d",&arr[i]);
  25. }
  26. int K, L, a;
  27. a=0;
  28. do
  29. {
  30. printf ("введите K\n");
  31. scanf("%d",&K);
  32. printf ("введите L\n");
  33. scanf("%d",&L);
  34. }
  35. while (K>L);
  36. for (i=0;i<n;i++)
  37. {
  38. if (fabs(double(arr[i]))<=L && fabs(double(arr[i]))>=K)
  39. {
  40. printf ("arr[%d]=%d\n", i+1, arr[i]);
  41. a=a+1;
  42. }
  43. }
  44. if (a==0)
  45. printf ("таких элементов нет\n");
  46. system ("pause");
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement