0

I wrote a program to find the symmetric elements in an array. Please suggest your version. How do you do it?

https://code.sololearn.com/c5ysO0dri5Kd/#c #include <stdio.h> #include <stdlib.h> int main() { int m, n, count= 0; scanf("%d %d\n", &m, &n); int arr[100][100]; if(n!=2){ printf("ReEnter the values. N value should be 2 for pairs to occur."); exit(1); } for(int i=0; i<m; i++){ for(int j=0; j<n; j++){ scanf("%d", &arr[i][j]); } } for(int i=0; i<m; i++){ for(int j=0; j<n; j++){ a= arr[j][i]; b= arr[i][j]; if(arr[i][j]== a && arr[j][i]==b){ printf("(%d, %d)\n", arr[i][j.3], arr[i][1]); count++; } } } if(count==0) printf("No symmetric pairs in the array!"); return 0; } //Considering array of size mxn where n is always 2. I am stuck later this. Please provide your idea/ Algorithm

28th Jul 2020, 6:02 AM
Tom
Tom - avatar
1 Respuesta
0
Hi are you doing this task? https://www.geeksforgeeks.org/given-an-array-of-pairs-find-all-symmetric-pairs-in-it/ Or is it something else ... An example for this maybe?
28th Jul 2020, 6:27 AM
Ipang