Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Didattica > Corsi A - F > Fondamenti di architettura e programmazione > Chiarimento operatori logici
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
Strong
.consigliere.

User info:
Registered: Dec 2007
Posts: 138 (0.02 al dì)
Location: Bergamo
Corso: Comunicazione Digitale
Anno:
Time Online: 1 Day, 9:25:25 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Chiarimento operatori logici

Salve,
volevo chiedervi un chiarimento, in particolare è l'esercizio 2 dello scritto del 2 marzo 2011.
Esattamente non ho capito questa parte:

int x = 4;
int y = 3;
boolean b = (x>=(x>y++) ? x++ : y++);

sostituendo i valori nella condizione si ha:
4>=(4>3) [e y diventa 3]

ora, nella parentesi il risultato dovrebbe essere un boolean con risultato true, e ora mi chiede se 4>= di un true? sbaglio a ragionare? qualcuno me lo spiega? thanks!

20-01-2012 15:06
Click Here to See the Profile for Strong Click here to Send Strong a Private Message Find more posts by Strong Add Strong to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Strong
.consigliere.

User info:
Registered: Dec 2007
Posts: 138 (0.02 al dì)
Location: Bergamo
Corso: Comunicazione Digitale
Anno:
Time Online: 1 Day, 9:25:25 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

*modifica [e y diventa 4, scusate].

20-01-2012 15:07
Click Here to See the Profile for Strong Click here to Send Strong a Private Message Find more posts by Strong Add Strong to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Strong
.consigliere.

User info:
Registered: Dec 2007
Posts: 138 (0.02 al dì)
Location: Bergamo
Corso: Comunicazione Digitale
Anno:
Time Online: 1 Day, 9:25:25 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Risolto da solo.
Le parentesi ingannano, equivale a dire boolean b = x>=x>y++ ? x++ : y++;
Quindi 4>=4>3 ? true :)

20-01-2012 16:04
Click Here to See the Profile for Strong Click here to Send Strong a Private Message Find more posts by Strong Add Strong to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
oksana213
.amico.

User info:
Registered: May 2008
Posts: 23 (0.00 al dì)
Location:
Corso:
Anno:
Time Online: 15:04:37 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Dato:
int x = 4;
int y = 3;
boolean b = (x>=(x>y++) ? x++ : y++);

Passo 1.
int x=4; int y=3;
(x>y++) ? x++ : y++, i.e. 4>3? SI, e incrementiamo x.

Passo 2.
int x=5; y=4 (y si è incrementato dopo la valutazione x>y++)
x>=(...)?, i.e.5>=5? SI.

Passo 3.
boolean b=TRUE.

Risultato finale:
int x = 5;
int y = 4;
boolean b = TRUE;

27-01-2012 20:04
Click Here to See the Profile for oksana213 Click here to Send oksana213 a Private Message Find more posts by oksana213 Add oksana213 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Strong
.consigliere.

User info:
Registered: Dec 2007
Posts: 138 (0.02 al dì)
Location: Bergamo
Corso: Comunicazione Digitale
Anno:
Time Online: 1 Day, 9:25:25 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by oksana213
Dato:
int x = 4;
int y = 3;
boolean b = (x>=(x>y++) ? x++ : y++);

Passo 1.
int x=4; int y=3;
(x>y++) ? x++ : y++, i.e. 4>3? SI, e incrementiamo x.

Passo 2.
int x=5; y=4 (y si è incrementato dopo la valutazione x>y++)
x>=(...)?, i.e.5>=5? SI.

Passo 3.
boolean b=TRUE.

Risultato finale:
int x = 5;
int y = 4;
boolean b = TRUE;


Grazie ma avevo già risolto.

28-01-2012 20:44
Click Here to See the Profile for Strong Click here to Send Strong a Private Message Find more posts by Strong Add Strong to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 06:27.    Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.034 seconds (79.15% PHP - 20.85% MySQL) con 29 query.