Skip to content

Instantly share code, notes, and snippets.

@duyet
Last active October 9, 2015 17:09
Show Gist options
  • Save duyet/1d346d3ee1313ed6ec6f to your computer and use it in GitHub Desktop.
Save duyet/1d346d3ee1313ed6ec6f to your computer and use it in GitHub Desktop.
Bài tập nhập xuất C
#include <stdio.h>
#include <math.h>
int main (void)
{
int a, b, c, d;
while (1) {
printf("Nhap 4 so:");
scanf("%d%d%d%d",&a, &b, &c, &d);
if (a >= 0 && b >= 0 && c >= 0 && d >= 0) break;
}
printf("\n Trung binh cong = %f", (float)(a+b+c+d)/4);
printf("\n Trung binh nhan = %f", (float)pow( a*b*c*d, 1.0/4 ));
printf("\n Trung binh dieu hoa = %f", (float) 4.0/(1.0/a + 1.0/b + 1.0/c + 1.0/d) );
return 0;
}
#include <stdio.h>
#include <math.h>
int main ()
{
int a, b, c, d;
do {
printf("Nhap 4 so:");
scanf("%d%d%d%d",&a, &b, &c, &d);
} while (a < 0 || b < 0 || c < 0 || d < 0);
printf("\n TB cong = %f", (float)(a+b+c+d)/4);
printf("\n TB nhan = %f", (float)pow( a*b*c*d, 1.0/4 ));
printf("\n TB dieu hoa = %f", (float) 4.0/(1.0/a + 1.0/b + 1.0/c + 1.0/d) );
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment