Skip to content

Instantly share code, notes, and snippets.

@SametSahin10
Created April 25, 2018 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SametSahin10/1e356f7cfa39c099dd3fb5b2aec5c569 to your computer and use it in GitHub Desktop.
Save SametSahin10/1e356f7cfa39c099dd3fb5b2aec5c569 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
int main() {
int n;
printf("Enter the number of x and y values: \n");
scanf("%d", &n);
int arrayOfX[n];
int arrayOfY[n];
printf("Enter the indicies of arrayOfX\n");
for(int i = 0; i < n; i++) {
scanf("%d", &arrayOfX[i]);
}
printf("\n");
printf("Enter the indicies of arrayOfY\n");
for(int i = 0; i < n; i++) {
scanf("%d", &arrayOfY[i]);
}
printf("\n");
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
if (arrayOfX[i] == arrayOfY[j]) {
printf("arrayOfX's %d.element is: %d\n", i + 1, arrayOfX[i]);
printf("arrayOfY's %d.element is: %d\n", j + 1, arrayOfY[j]);
printf("Difference between indicies is %d\n", abs(i - j));
printf("\n");
}
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment