Advertisement
Robert_Manea

min/max pe vector nesortat

Dec 1st, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int main(){
  6. int n,j,i,v[30],aux=0,min, max=0;
  7.  
  8. printf("introdu n:");
  9. scanf("%d",&n);
  10.  
  11. for(i=0;i<n;i++){
  12. scanf("%d",&v[i]);
  13. min = v[i];
  14. }
  15.  
  16. for(int i=0;i<n;i++){
  17. if(v[i]> max){
  18. max = v[i];
  19. }
  20. }
  21.  
  22. for(int i=0;i<n;i++){
  23. if(v[i] < min){
  24. min = v[i];
  25. }
  26. }
  27.  
  28. printf("Minimul este: %d\n", min);
  29. printf("Maximul este: %d", max);
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement