xTremeSurfer Posted March 17, 2012 Report Posted March 17, 2012 #include<iostream.h>int main(){int i,n,v[20],min,gasit=0;cout<<"n=";cin>>n;for(i=1;i<=n;i++)cin>>v;for(i=1;i<=n && !gasit;i++)if(v%2==0){min=v;gasit=1;}for(i=1;i<=n;i++)if(v%2==0 &&v<min)min=v;cout<<min;}Problema afiseaza minimul par dintr-un sir de numere dat .Nu inteleg ce face !gasit in programul asta . Imi poate explica cineva? thx Quote
totti93 Posted March 17, 2012 Report Posted March 17, 2012 E ca si cum ai spune:for(i=1;i<=n;i++)if(v[i]%2==0){min=v[i];break;}Acesta seteaza variabila `min` pe valoarea primului numar par.Restul codului e comparatia cu acest `min`. Quote
icebird Posted March 17, 2012 Report Posted March 17, 2012 Gasit e o variabla de tip int, daca ii pui ! in fata e echivalent cu gasit==0, adica daca gasit e nul. Quote
phreak Posted March 17, 2012 Report Posted March 17, 2012 ! e logical not ( negation )Truth table - Wikipedia, the free encyclopedia Quote
cifratorul Posted March 17, 2012 Report Posted March 17, 2012 Logical Negation Operator: ! (C++) Quote
xTremeSurfer Posted March 17, 2012 Author Report Posted March 17, 2012 Multumesc . Acum insfarsit am inteles . Quote