Advertisement
vallec

26

Dec 12th, 2022
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 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[6,6] sustaveni ot realni chisla sys stoinosti v intervala [0; 99.99]. Programata da izvurshi slednite deistviq:\n");
  7. printf("Elementite na masiva A ravni na svoite susedni elementi da se iznesat v masiva C[L,3] zaedno s tehnite indeksi.\n");
  8. printf("Avtor: ..........\n");
  9.  
  10. double A[6][6];
  11.  
  12. for(int i = 0; i < 6; i++){
  13. for(int j = 0; j < 6; j++){
  14. printf("A[%d][%d] = ", i, j);
  15. scanf("%lf", &A[i][j]);
  16. }
  17. }
  18.  
  19. printf("---------------\n");
  20.  
  21. for(int i = 0; i < 6; i++){
  22. for(int j = 0; j < 6; j++){
  23. printf("A[%d][%d] = %lf\n", i, j, A[i][j]);
  24. }
  25. }
  26.  
  27. int foundIndexes = 0;
  28. for(int i = 0; i < 6; i++){
  29. for(int j = 1; j < 6; j++){
  30. if(j == 6){
  31. break;
  32. }
  33. if(A[i][j-1] == A[i][j]){
  34. foundIndexes++;
  35. }
  36. }
  37. }
  38.  
  39.  
  40. int C[6][foundIndexes];
  41. int row, col = 0;
  42.  
  43. for(int i = 0; i < 6; i++){
  44. for(int j = 0; j < foundIndexes; j++){
  45. C[i][j] = -1;
  46. }
  47. }
  48.  
  49. for(int i = 0; i < 6; i++){
  50. for(int j = 1; j < 6; j++){
  51. if(j == 6){
  52. break;
  53. }
  54. if(A[i][j-1] == A[i][j]){
  55. C[row][col] = j;
  56. col++;
  57. }
  58. }
  59. row++;
  60. col = 0;
  61. }
  62.  
  63. printf("Results:\n");
  64. int found = 0;
  65. for(int i = 0; i < 6; i++){
  66. for(int j = 0; j < foundIndexes; j++){
  67. if(C[i][j] != -1){
  68. printf(" [%d,%d] - [%d,%d]", i, C[i][j], i, C[i][j] + 1);
  69. found = 1;
  70. }
  71. }
  72. if(found == 1){
  73. printf("\n");
  74. found = 0;
  75. }
  76.  
  77. }
  78.  
  79.  
  80. return 0;
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement