Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are making some very basic mistakes like not even taking the iput correctly ,not checking runtime errors like the one by accessing an array element out of bounds.</p> <p>I suggest that you should debug your code properly before you post here.</p> <p>As far as the answer to your code is concerned, this is gonna be the algo.. <strong><em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em></strong><em>LOGIC</em><strong><em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>***</strong></p> <p>First of all sort all the three arrays.</p> <p>Secondly pick up the first element of any array (say C), and compare it the second one (say B) until you find a number in B which is greater than or equal to C[0].If they are equal start finding the number in A (if you find any such number it is connctive) else take the next element of C.</p> <p><em><strong></em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>***</strong><em>LOGIC ENDS</em><strong><em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>*</strong></p> <p><em><strong></em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em></strong><em>CODE</em><strong><em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**</strong></p> <pre><code>#include &lt;iostream&gt; using namespace std; void sort_array(int * X); int main() { int A[5] , B[5] , C[5]; int i=0,j,h; cout &lt;&lt; "THE PROGRAM TAKES 3 GRAGHS ONLY\n"; cout &lt;&lt; "\n enter the Graph 1 \n"; for (i=0 ; i&lt;5 ; i++) cin &gt;&gt; A[i]; cout &lt;&lt; "\n enter the Graph 2 \n"; for (i=0 ; i&lt;5 ; i++) cin &gt;&gt; B[i]; cout &lt;&lt; "\n enter the Graph 1 \n"; for (i=0 ; i&lt;5 ; i++) cin &gt;&gt; C[i]; sort_array(A); sort_array(B); sort_array(C); i=0; for (j=0;j&lt;5;j++) { for(h=0;h&lt;5;h++) { if (C[j]&lt;=B[h]) { break; } } if (C[j]==B[h]) { for(; i&lt;5 ;i++) { if(A[i]&gt;=C[j]) { break; } } if(A[i]==C[j]) { cout&lt;&lt;"\n "&lt;&lt;A[i]&lt;&lt;" connective\n"; } } } return 0; } void sort_array(int * X) { for( int i=0; i&lt;4 ; i++) { for( int j=0; j&lt;5-i ; j++) { if(X[i]&gt;X[i+1]) { swap(X[i],X[i+1]); } } } } ******************************CODE ENDS************************************** </code></pre>
    singulars
    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