Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. typedef int bool;
  4. #define true 0
  5. #define false 1
  6.  
  7. int egyszam(int tomb[], int meret) {
  8. int i;
  9. int min = tomb[0];
  10. bool volt = false;
  11. for (i = 1; i < meret; i++) {
  12. if (tomb[i] < min) {
  13. volt = false;
  14. min = tomb[i];
  15. }
  16. else if (tomb[i] == min) {
  17. volt = true;
  18. }
  19. }
  20.  
  21. if (volt == false) {
  22. return min;
  23. }
  24. return -1;
  25.  
  26. }
  27.  
  28. int main()
  29. {
  30. int tomb[5] = { 2, 5, 6, 2, 4 };
  31. printf("%d\n", egyszam(tomb, 5));
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement