Jump to content
Sign in to follow this  
Krazzi

Comparar Valores

Recommended Posts

Krazzi

Boas.....

Tou com problemas em comparar valores entre 2 registo num struct...como e que posso fazer isso se ambos sao int e não sao strings?

Share this post


Link to post
Share on other sites
The Loser

Não percebi o que queres.

Mostra código e concretiza melhor a tua dúvida.


I intend to live forever. So far so good.

Share this post


Link to post
Share on other sites
Krazzi

struct pessoa{

char Nome[30[;

int salario;

}

e um exemplo.....depois de inserir dois vezes  essa pessoa queria comparar os salarios dessas duas pessoas e saber qual e o maior

Share this post


Link to post
Share on other sites
Triton
pessoa p1; p1.salario = 100;
pessoa p2; p2.salario = 150;

if(p1.salario > p2.salario)
    // do something


<3 life

Share this post


Link to post
Share on other sites
Krazzi

Mas se por exemplo eu quiser saber qual e o maior posso fazer do estilo

int max=0;

if(max<p.salario)

  max=p.salario

????

Share this post


Link to post
Share on other sites
Triton
pessoa p1; p1.salario = 100;
pessoa p2; p2.salario = 150;
int max;

if(p1.salario > p2.salario)
    max = p1.salario;
else
    max = p2.salario;


<3 life

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.