Last active
October 9, 2015 17:09
-
-
Save duyet/1d346d3ee1313ed6ec6f to your computer and use it in GitHub Desktop.
Bài tập nhập xuất C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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