//code Dung NV
#include <stdio.h>
#include <conio.h>
#include <windows.h>
void nhapmang(float a[],int n)
{
int i;
for (i=0;i<n;i++)
{
printf("\nNhap phan tu thu %5d : ",i);
scanf("%f",&a[i]);
}
}
void xemmang(float a[],int n)
{
int i;
printf("\n");
for (i=0;i<n;i++)
printf(" %5.2f ",a[i]);
printf("\n");
}
float tbcong(float a[],int n)
{
int i;
float s=0;
for (i=0;i<n;i++) s+=a[i];
return s/n;
}
void main()
{
int n;
float a[500];
printf("\nnhap so phan tu trong mang : ");
scanf("%d",&n);
nhapmang(a,n);
xemmang(a,n);
printf("\ntrung binh cong cua mang: %5.3f ",tbcong(a,n));
getch();
}
No comments:
Post a Comment