Home > Back-end >  Novice los valley village program exercises
Novice los valley village program exercises

Time:03-09

Anyone who can help to see what are the logical mistakes, why not ah

CodePudding user response:

 # include & lt; stdio.h> 
#include

Int main ()
{
Int I, j, k, n;
Int * arr, m=0;

The scanf (" % d ", & amp; N);


Arr=(int *) malloc (sizeof (int) * n);
if (! Arr)
return -1;

For (I=0; I & lt; n; I++)
The scanf (" % d ", & amp; Arr [I]);

For (I=0; I & lt; n; I++) {
For (j=0; J & lt; n; J++) {
If (I==j)
continue;
For (k=j + 1; K & lt; n; K++) {
If (k==I | | k==j)
continue;
If (arr [I]==arr [j] + arr [k]) {
Printf (" % d=% d + % d \ n ", arr [I], arr [k], arr [j]);
m++;
}
}
}
}
Printf (" % d \ n ", m);
Free (arr);

return 0;
}

For your reference ~

Try this version ~
  • Related