Advertisement
vallec

1

Dec 14th, 2022
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 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 masivite A[13], B[18], C[20] susteveni ot realni chisla sys stoinosti v intervala [0; 99.99]. Programata da izvurshi slednite deistviq:\n");
  7. printf("Da se sviqt masivite A B C posredstvom izkluchvane na nulevite elementi i elementite po - malki ot 5.5\n");
  8. printf("Trite masiva da se obedinqt v nov masiv D[K, 3] kato svobodnite kletki se zapulnqt s 0\n");
  9. printf("Avtor: ..........\n");
  10.  
  11. int i, x, y, a, b, c, row, col;
  12.  
  13.  
  14. //arrayA
  15. printf("Vavedi razmer za A ot 1 do 13: ");
  16. scanf("%d", &a);
  17. double arrayA[a];
  18. printf("Vavedi chisla za A: ");
  19. for (i = 0; i < a; i++){
  20. scanf("%lf", &arrayA[i]);
  21. }
  22.  
  23. printf("Otpechatvane predi obrabotka: \n" );
  24. for(i = 0; i < a; i++) {
  25. printf("%lf\n", arrayA[i]);
  26. }
  27.  
  28. printf("Otpechatvane sled obrabotka: ");
  29. for (i = 0; i < a; i++){
  30. if (arrayA[i] > 5.5 && arrayA[i] != 0){
  31. printf("%lf\n", arrayA[i]);
  32. }else{
  33. continue;
  34. }
  35. }
  36.  
  37.  
  38.  
  39. //arrayB
  40. printf("Vavedi razmer za B ot 1 do 18: ");
  41. scanf("%d", &b);
  42. double arrayB[b];
  43. printf("Vavedi chisla za B: ");
  44. for (x = 0; x < b; x++){
  45. scanf("%lf", &arrayB[x]);
  46. }
  47.  
  48. printf("Otpechatvane predi obrabotka: ");
  49. for(x = 0; x < b; x++) {
  50. printf("%lf\n", arrayB[x]);
  51. }
  52.  
  53. printf("Otpechatvane sled obrabotka: ");
  54. for (x = 0; x < b; x++){
  55. if (arrayB[x] > 5.5 && arrayB[x] != 0){
  56. printf("%lf\n", arrayB[x]);
  57. }else{
  58. continue;
  59. }
  60. }
  61.  
  62.  
  63.  
  64. //arrayC
  65. printf("Vavedi razmer za C ot 1 do 20: ");
  66. scanf("%d", &c);
  67. double arrayC[c];
  68. printf("Vavedi chisla za C: ");
  69. for (y = 0; y < c; y++){
  70. scanf("%lf", &arrayC[y]);
  71. }
  72.  
  73. printf("Otpechatvane predi obrabotka: ");
  74. for(y = 0; y < 20; y++) {
  75. printf("%lf\n", arrayC[y]);
  76. }
  77.  
  78. printf("Otpechatvane sled obrabotka: ");
  79. for (y = 0; y < c; y++){
  80. if (arrayC[y] > 5.5 && arrayC[y] != 0){
  81. printf("%lf\n", arrayC[y]);
  82. }else{
  83. continue;
  84. }
  85. }
  86.  
  87. int maxNum = a > b ? (a > c ? a : c) : (b > c ? b : c);
  88. double D[3][maxNum];
  89. int count = 1;
  90.  
  91.  
  92. for(row = 0; row < 3; row++){
  93. if(count > 3) break;
  94. for(col = 0; col < maxNum; col++){
  95. switch(row){
  96. case 0:
  97. if (arrayA[col] > 5.5){
  98. D[row][col] = arrayA[col];
  99. } else {
  100. D[row][col] = 0;
  101. }
  102. break;
  103. case 1:
  104. if (arrayB[col] > 5.5){
  105. D[row][col] = arrayB[col];
  106. } else {
  107. D[row][col] = 0;
  108. }
  109. break;
  110. case 2:
  111. if (arrayC[col] > 5.5){
  112. D[row][col] = arrayC[col];
  113. } else {
  114. D[row][col] = 0;
  115. }
  116. break;
  117. }
  118.  
  119. }
  120. count++;
  121. }
  122.  
  123.  
  124. count = 1;
  125. printf("Otpechatvane D: \n");
  126. for(row = 0; row < 3; row++){
  127. if(count > 3) break;
  128. for(col = 0; col < maxNum; col++){
  129. printf("%lf ", D[row][col]);
  130. }
  131. printf("\n");
  132. count++;
  133. }
  134.  
  135.  
  136. return 0;
  137.  
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement