@mad_putin , why in for (... && k <2; ...)?
After all, real actions (namely, c [nc ++] = a [i]) are performed only for k == 0 ???
Those. You are looking for something in this internal for (...) and only if you have not found it, then add a [i] to c []. Therefore, it is probably necessary to rewrite so
for (i=0;i<na;i++){ for (j1=0,j2=0,k=0;j1<na && j2<nb;j1++,j2++){ if ((a[i]==a[j1] && i!=j1) || a[i]==b[j2]) { k++; break; } } if (k==0)c[nc++]=a[i]; }
I ventured to replace ||
on &&
since I assume that in a [] na elements, and in b [] nb and you want to refer only to existing ones.
And on the pseudocode, I would write the entire contents of the outer loop as
for (i = 0; i < na; i++) { Добавим к c[] те a[i], которые не повторяются в a[] и отсутствуют в b[]; } // теперь в c[] nc элементов