Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int main()
- {
- 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");
- printf("Elementite na masiva A ravni na svoite susedni elementi da se iznesat v masiva C[L,3] zaedno s tehnite indeksi.\n");
- printf("Avtor: ..........\n");
- double A[6][6];
- for(int i = 0; i < 6; i++){
- for(int j = 0; j < 6; j++){
- printf("A[%d][%d] = ", i, j);
- scanf("%lf", &A[i][j]);
- }
- }
- printf("---------------\n");
- for(int i = 0; i < 6; i++){
- for(int j = 0; j < 6; j++){
- printf("A[%d][%d] = %lf\n", i, j, A[i][j]);
- }
- }
- int foundIndexes = 0;
- for(int i = 0; i < 6; i++){
- for(int j = 1; j < 6; j++){
- if(j == 6){
- break;
- }
- if(A[i][j-1] == A[i][j]){
- foundIndexes++;
- }
- }
- }
- int C[6][foundIndexes];
- int row, col = 0;
- for(int i = 0; i < 6; i++){
- for(int j = 0; j < foundIndexes; j++){
- C[i][j] = -1;
- }
- }
- for(int i = 0; i < 6; i++){
- for(int j = 1; j < 6; j++){
- if(j == 6){
- break;
- }
- if(A[i][j-1] == A[i][j]){
- C[row][col] = j;
- col++;
- }
- }
- row++;
- col = 0;
- }
- printf("Results:\n");
- int found = 0;
- for(int i = 0; i < 6; i++){
- for(int j = 0; j < foundIndexes; j++){
- if(C[i][j] != -1){
- printf(" [%d,%d] - [%d,%d]", i, C[i][j], i, C[i][j] + 1);
- found = 1;
- }
- }
- if(found == 1){
- printf("\n");
- found = 0;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement