Advertisement
vallec

Boris

Dec 12th, 2022
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main()
  5. {
  6. printf("Da se sustavi programa za obrabotka na masiva A[N,N], kudeto dannite sa realni chisla v intervala [-1000;1000]. Programata da izvurshi slednite deistviq:\n");
  7. printf("Da se obrazuva ednomeren masiv C, elementite na koito sa elementite ot masiva A v zadaden interval [K - L]\n");
  8. printf("Polucheniqt masiv da se sortira po golemina\n");
  9. printf("Avtor: ..........\n");
  10.  
  11. int n;
  12.  
  13. printf("Vavedi golemina na A: ");
  14. scanf("%d", &n);
  15. double A[n][n];
  16.  
  17. for(int i = 0; i < n; i++){
  18. for(int j = 0; j < n; j++){
  19. printf("A[%d][%d] = ", i, j);
  20. scanf("%lf", &A[i][j]);
  21. }
  22. }
  23.  
  24. printf("---------------\n");
  25.  
  26. for(int i = 0; i < n; i++){
  27. for(int j = 0; j < n; j++){
  28. printf("A[%d][%d] = %lf\n", i, j, A[i][j]);
  29. }
  30. }
  31.  
  32. double k, l;
  33. int count = 0;
  34. printf("Vavedi K: ");
  35. scanf("%lf", &k);
  36. printf("Vavedi L: ");
  37. scanf("%lf", &l);
  38.  
  39. for(int i = 0; i < n; i++){
  40. for(int j = 0; j < n; j++){
  41. if(A[i][j] >= k && A[i][j] <= l){
  42. count++;
  43. }
  44. }
  45. }
  46.  
  47. double C[count];
  48. int index = 0;
  49. for(int i = 0; i < n; i++){
  50. for(int j = 0; j < n; j++){
  51. if(A[i][j] >= k && A[i][j] <= l){
  52. C[index] = A[i][j];
  53. index++;
  54. }
  55. }
  56. }
  57. printf("Rezultati: \n");
  58. printf("A)\n");
  59. for(int i = 0; i < n; i++){
  60. printf("C[%d] = %lf\n", i, C[i]);
  61. }
  62.  
  63. int a;
  64.  
  65. for (int i = 0; i < count; ++i)
  66. {
  67. for (int j = i + 1; j < count; ++j)
  68. {
  69. if (C[i] < C[j])
  70. {
  71. a = C[i];
  72. C[i] = C[j];
  73. C[j] = a;
  74. }
  75. }
  76. }
  77.  
  78. printf("B)\n");
  79. for(int i = 0; i < n; i++){
  80. printf("C[%d] = %lf\n", i, C[i]);
  81. }
  82.  
  83.  
  84. return 0;
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement