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)
Sacred Thought
5 May 2024 Hari Om Verse 50-51, chapter two: In this chapter two Shree krishna explains a simple way of living. Free from desires and void ...
-
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&quo...
-
Define a Python function ascending(l) that returns True if each element in its input list is at least as big as the one before it. Here...
got it.. Thank you soo much
ReplyDelete