Jump to content
middleftw

Problema eficienta

Recommended Posts


minp=0;
maxi=999999999; //(am uitat ce tip e)
fin>>nr;
if(nr%2==0)
minp=nr;
else maxi=nr;
while(c==1)
{
fin>>nr;
if(nr%2==0)
{
if(nr>=minp)
minp=nr;
else c=0;
}
else
{
if(nr<=maxi)
maxi=nr;
else c=0;
}
}
if(c==0)
fout<<"Nu exista";
else fout<<"Exista";

Bun, acum sa-ti explic eficienta:

1. Nu am salvat nimic in memorie.

2. Rezolv totul in timp ce citesc numerele.

Si eu am maine la info bac :) Bafta

PS:Am facut doar o parte din program, algoritmul care rezolva problema, nu am mai scris si incluziunile sau initializarile.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...