Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

73
Views
Cómo hago esto en la declaración de cambio

Convierta los siguientes códigos en una declaración de cambio:

 int a = 5, b = 10, c = 15, choice; choice = a > b && a>c ? a: (b > c ? b: c); printf(“%d”, choice);

Intento de esta manera.

 #include<stdio.h> int main() { int a = 5, b = 10, c = 15, choice; switch(choice) { case 'a > b && a>c': { choice=a; break; } case 'b > c': { choice=b; break; } default : { choice=c; break; } } printf("%d",choice); }

pero su salida siempre viene C. Si doy a = 15, b = 10, c = 5, la salida sale 5 donde debería ser 15. ¿Dónde hice mal?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Desea que el mayor de ( a, b, c ) sea la choice . switch(logical-condition) evalúa como true o false .

No se recomienda usar el switch en este escenario. Sin embargo, para el ángulo de aprendizaje:

 #include <stdbool.h> // for true/false flags switch (a > b) { case true : switch (a > c) { case true: choice = a; break; case false: choice = c; //break; //redundant } break; case false: switch (b > c) { case true: choice = b; break; case false : choice = c; //break; //redundant } //break; //redundant }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!