Guest User

Untitled

a guest
Jul 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. /*Pregunta 5
  2.  
  3. Construya una función llamada f1 que recibe dos punteros a variables estructura del tipo st
  4. y retorna un puntero a la variable estructura que tiene el campo c1 menor o NULL si son iguales.
  5. struct st {
  6. int c1;
  7. int c2;
  8. };
  9. */
  10. #include <stdio.h>
  11. struct st{
  12. int c1;
  13. int c2;
  14. };
  15. struct st* f1(struct st*p1,struct st*p2);
  16.  
  17. main(){
  18. struct st pico={
  19. 10,
  20. 15,
  21. };
  22. struct st taldo={
  23. 5,
  24. 2,};
  25. printf("%d",f1(&pico,&taldo)->c1);
  26. getchar();
  27. getchar();
  28. }
  29. struct st* f1(struct st*p1,struct st*p2){
  30. if(p1->c1< p2->c1)
  31. return p1;
  32. if(p2->c1 <p1->c1)
  33. return p2;
  34. if(p2->c1==p1->c1)
  35. return NULL;
  36. }
Add Comment
Please, Sign In to add comment