# C ++ cycles in PARADISE

Tell me how to write this cycle:

``for (j1 = 0, j2 = 0, k = 0; (j1 < na || j2 < nb) && k < 2; j1++, j2++) { ... }` `

on pseudocode or russian algorithmic language?

Full cycle:

` `for (i = 0; i < na; i++) { for (j1 = 0, j2 = 0, k = 0; (j1 < na || j2 < nb) && k < 2; j1++, j2++) { if ((a[i] == a[j1] && i != j1) || a[i] == b[j2]) k++; } if (k == 0) c[nc++] = a[i]; }` `
• I do not understand what things, what pseudocode? - igumnov
• Corrected the issue - kaneru
• so what? or need obscene? assign i = 0; while i is less na add i assign j1 = 0, j2 = 0, k = 0 while (j1 less na or j2 less nb) and k less than 2 add j1 add j2 if ... then .... everything is all if .. ... then ... everything is all END. I have a question for ... why? - zb '

@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 элементов` `