Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // tinh gia trij nho nhat trong mang so thuc
- // Khai bao cac ham thu vien neu cos
- #include<stdio.h>
- #include<conio.h>
- #define SIZE 100
- void nhap(float a[],int &n);
- float max(float a[],int n);
- void main()
- {
- float a[SIZE];
- int n;
- nhap(a,n);
- float t=max(a,n);
- printf("%.2f",t);
- }
- void nhap(float a[],int &n)
- {
- scanf("%d",&n);
- float x;
- for(int i=0;i<n;i++)
- {
- scanf("%f",&x);
- a[i]=x;
- }
- }
- float max(float a[],int n)
- {
- float lonnhat=a[0];
- for(int i=0;i<n;i++)
- {
- if(a[i]>lonnhat)
- lonnhat=a[i];
- }
- return lonnhat;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement