Input Specification: The first line contains the size N1 of the first array. Next line give the contents of the first array. Next line contains the size N2 of the second array. Next line give the contents of the second array.Output Format: Output must be a single number which is the smallest number occurring in the first array that does not occur in the second. In case there is no such number, output NO.#include<stdio.h> # define MAX_SIZE 20 int main(){ int a[MAX_SIZE], b[MAX_SIZE],comn[MAX_SIZE]; int na,nb,count=0,g=0; scanf("%d",&na); if(na>0) { for(int i=0;i<na;i++) { scanf("%d ",&a[i]); } scanf("%d",&nb); for(int j=0;j<nb;j++) { scanf("%d ",&b[j]); } for(int k=0;k<na;k++){ for(int l=0;l<nb;l++) { if(a[k]==b[l]) { count++; } } if(count==0) { comn[g]=a[k]; g+=1; } if(count>=1) { ; } count=0; } int smallest=comn[0]; for(int j=0;j<g;j++) { if (comn[j]<smallest) { smallest = comn[j]; } } if(g!=0) { printf("%d", smallest); } else { printf("NO"); } } else { printf("NO"); } return 0; }ThanksHappy Computing !
I am also active at:
Sunday, February 25, 2018
C program : Given two arrays of integers output the smallest number in the first array not present in the second one.
Subscribe to:
Post Comments (Atom)
इश्क में ग़ैरत-ए-जज़्बात ने रोने ना दिया - सुदर्शन फ़ाकिर
इश्क में ग़ैरत-ए-जज़्बात ने रोने ना दिया वरना क्या बात थी किस बात ने रोने ना दिया आप कहते थे कि रोने से ना बदलेंगे नसीब उमर भर आप की इस बात...
-
Acronym Full Form AJAX Asynchronous JavaScript and XML API Application Programming Interface APK Android Application Package ASP Activ...
-
#include<stdio.h> int main() { int M,N,q; scanf("%i %i",&M, &N); if((M%N)!=0) {printf("0...
-
"A good company understands that problem solving ability and the ability to learn new things are far more important than knowledge o...
got it.. Thank you soo much
ReplyDelete