Advertisement
nguyenhappy92

Tìm “giá trị nhỏ nhất” trong mảng số thực

Nov 3rd, 2015
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. // Tinh gia tri nho nhat cua mang so thuc
  2. // Khai bao cac ham thu vien neu co
  3. #include<stdio.h>
  4. #include<conio.h>
  5.  
  6. #define SIZE 100
  7.  
  8. void nhap(float a[],int &n)
  9. {
  10. scanf("%d",&n);
  11. float x;
  12. for(int i=0;i<n;i++)
  13. {
  14. scanf("%f",&x);
  15. a[i]=x;
  16. }
  17. }
  18. float nhonhat(float a[],int n)
  19. {
  20. float min=a[0];
  21. for(int i=0;i<n;i++)
  22. {
  23. if(a[i]<min)
  24. min=a[i];
  25. }
  26. return min;
  27. }
  28. void main()
  29. {
  30. float a[SIZE];
  31. int n;
  32. nhap(a,n);
  33. printf("%.2f",nhonhat(a,n));
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement