Compatibility

QUESTION

Two arrays are said to be compatible if they are of the same size and if the ith element in the first array is greater than or equal to the ith element in the second array for all i.Write a program to find whether 2 arrays are compatible or not.\n\nInput Format:\n\nInput consists of 2n+1 integers. The first integer corresponds to \”n\” , the size of the array. The next \”n\” integers correspond to the elements in the first array. The last ‘n’ integers correspond to the elements in the second array. Assume that the maximum value of n is 15.\n\nOutput Format:\nRefer sample output for details.\n.

“TESTCASE_1”: “5 \n2 3 6 8 1 \n1 2 5 7 1\n###—###SEPERATOR—###—\nCompatible”, “TESTCASE_2”: “5\n2 3 6 8 1\n1 1 1 1 2\n###—###SEPERATOR—###—\nIncompatible”, “TESTCASE_3”: “5\n3 2 3 4 5\n1 2 3 4 5\n###—###SEPERATOR—###—\nCompatible”, “TESTCASE_4”: “4\n1 2 3 4\n4 3 2 1 \n###—###SEPERATOR—###—\nIncompatible”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0

ANSWER

#include<stdio.h>
int main()

{

int n,a[15],b[15],i,c=0;

scanf("%d",&n);

for(i=0;i<2*n;i++)
{if(i<n)scanf("%d",&a[i]);
else
{
scanf("%d",&b[i-n]);
if(c==0)if(a[i-n]<b[i-n])c=1;
}
}
if(c==0)printf("Compatible");
else
printf("Incompatible");
return 0;
}

ANSWER

baixaicrack.com

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.