Note that there are some explanatory texts on larger screens.

plurals
  1. POMerge two arrays and omit all repeating elements
    primarykey
    data
    text
    <p>I have 2 arrays. Input 1 and Input 2. Suppose input 1 has {1,1,2,3,3,4,5} and input 2 has {4,2,6,7,8}. Merged array {1,1,2,3,3,4,5,4,2,6,7,8}</p> <p>After sorting my merged array looks like {1,1,2,2,3,3,4,4,5,6,7,8} </p> <p>My output should be like {5,6,7,8} because those are non-repeating elements. It should have neither occurred twice in 1st nor once in 1st and once in 2nd. </p> <p>I have put both the arrays into one single array(merged both). Sorted it and removed duplicates also. I am getting the output like {1,2,3,4,5,6,7,8} but i should not get 1,2,3,4 as they all have occurred twice in the merged array.</p> <p>Please help me to finish the program soon. Thanks in advance.</p> <p>I cant use structures. Thats my task.</p> <pre><code>#include&lt;stdio.h&gt; #include&lt;conio.h&gt; main() { int a[10],b[10],c[10],i,j,n,n1,temp; clrscr(); printf("enter the no of ele in array1\n"); scanf("%d",&amp;n); printf("enter 1st array elements\n"); for(i=0;i&lt;n;i++) { scanf("%d",&amp;a[i]); } printf("enter size of 2nd array"); scanf("%d",&amp;n1); printf("enter 2nd array elements\n"); for(i=0;i&lt;n;i++) { scanf("%d",&amp;b[i]); } for(i=0;i&lt;n;i++) { c[i]=a[i]; } j=0; for(i=n;i&lt;n+n1;i++) { c[i]=b[j]; // printf("\n2nd array values are %d",c[i]); j++; } for(i=0;i&lt;n+n1;i++) { printf("%d\n",c[i]); } for(i=0;i&lt;n-1;i++) { for(j=0;j&lt;n-i-1;j++) { if(c[j]&gt;c[j+1]) { temp=c[j]; c[j]=c[j+1]; c[j+1]=temp; } } } for(j=0;j&lt;n+n1;j++) { printf("sorted is %d\n",c[j]); } for(i=0;i&lt;n+n1;i++) { if(c[i]==c[i+1]) { temp=c[i]; // printf("%d r d rep.ele\n",c[i]); } else printf("%d r d ele\n",c[i]); } getch(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload