Advertisement
vallec

lubo

Dec 12th, 2022
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 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 M1[10], M2[15], M3[20] sustaveni ot celi chisla sus stoinosti v intervala [0; 999]. Programata da izvurshi slednite deistviq:\n");
  7. printf("Namirane na nomerata na elementite v ednomeren masiv, po - golemi ot chisloto M i po - malki ot sumata na predshestvashtite elementi.\n");
  8. printf("Avtor: ..........\n");
  9.  
  10. int M1[10], M2[15], M3[20];
  11. int M4[45];
  12.  
  13. for(int i = 0; i < 10; i++){
  14. printf("M1[%d] = ", i);
  15. scanf("%d", &M1[i]);
  16. }
  17.  
  18. for(int i = 0; i < 15; i++){
  19. printf("M2[%d] = ", i);
  20. scanf("%d", &M2[i]);
  21. }
  22.  
  23. for(int i = 0; i < 20; i++){
  24. printf("M3[%d] = ", i);
  25. scanf("%d", &M3[i]);
  26. }
  27.  
  28. for(int i = 0; i < 45; i++){
  29. M4[i] = -1;
  30. }
  31.  
  32. printf("----------------\n");
  33.  
  34. for(int i = 0; i < 10; i++){
  35. printf("M1[%d] = %d\n", i, M1[i]);
  36. }
  37.  
  38. for(int i = 0; i < 15; i++){
  39. printf("M2[%d] = %d\n", i, M2[i]);;
  40. }
  41.  
  42. for(int i = 0; i < 20; i++){
  43. printf("M3[%d] = %d\n", i, M3[i]);
  44. }
  45.  
  46. int m;
  47. printf("---------------\n");
  48. printf("M = ");
  49. scanf("%d", &m);
  50.  
  51. //printf("M1 Rezultat: \n");
  52. for(int i = 2; i < 10; i++){
  53. if(M1[i] > m && M1[i-2] + M1[i-1] > M1[i]){
  54. //printf("Chislo: %d, Index: %d\n", M1[i], i);
  55. M4[i] = i + 1;
  56. }
  57. }
  58.  
  59. //printf("M2 Rezultat: \n");
  60. for(int i = 2; i < 15; i++){
  61. if(M2[i] > m && M2[i-2] + M2[i-1] > M2[i]){
  62. //printf("Chislo: %d, Index: %d\n", M2[i], i);
  63. M4[i+9] = i + 1;
  64. }
  65. }
  66.  
  67. //printf("M3 Rezultat: \n");
  68. for(int i = 2; i < 20; i++){
  69. if(M3[i] > m && M3[i-2] + M3[i-1] > M3[i]){
  70. //printf("Chislo: %d, Index: %d\n", M3[i], i);
  71. M4[i+24] = i + 1;
  72. }
  73. }
  74.  
  75. // Printirame nomerata na elementite
  76.  
  77. for(int i = 0; i < 45; i++){
  78. if(i == 0){
  79. printf("\nM1: \n");
  80. } else if (i == 9) {
  81. printf("\nM2: \n");
  82. } else if (i == 24){
  83. printf("\nM3: \n");
  84. }
  85.  
  86. if(M4[i] != -1){
  87. printf(" %d", M4[i]);
  88. }
  89. }
  90.  
  91. return 0;
  92.  
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement