26.09.2015 Views

PROGRAMSKI JEZICI 2

Предавање 1

Предавање 1

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Dynamic memory allocation<br />

• *pprime = 2; // Insert three<br />

• *(pprime+1) = 3; // seed primes<br />

• *(pprime+2) = 5;<br />

• do<br />

• { trial += 2; // Next value for checking<br />

• found = 0; // Set found indicator<br />

• for(int i = 0; i < count; i++)<br />

• // Division by existing primes<br />

• { found =(trial % *(pprime+i)) == 0; // True for exact division<br />

• if(found) // If division is exact<br />

• break; // it's not a prime }<br />

• if (found == 0) // We got one... so save it in<br />

• *(pprime+count++) = trial; // primes array }<br />

• while(count < max);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!