Source code bài 2

#include <stdio.h>
void main()
{
int n,i;
float x,s,s1,s2,max,min;
printf(“nhap vao n: “); scanf(“%d”,&n);
printf(“nhap vao pt thu 1: “); scanf(“%f”,&x);
min=x; max=x; s1=x; s2=x*x;
for (i=2;i<=n;i++)
{
printf(“nhap vao pt thu %i: “,i);
scanf(“%f”,&x);
s1+=x; s2+=x*x;
if (x>max) max=x;
if (x<min) min=x;
}
s=n*(max*max+min*min)+2*s2-2*s1*(max+min)+n/2.0*(max-min)*(max-min);
printf(“s= %f”,s);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s