1、
#include <stdio.h> #include <math.h> int main(void) { double x; puts("please input an double value."); printf("x = "); scanf("%lf", &x); printf("result: %f. ", sqrt(x)); return 0; }
2、函数版
#include <stdio.h> #include <math.h> double side(double x) { return sqrt(x); } int main(void) { double x; puts("please input an double value."); printf("x = "); scanf("%lf", &x); printf("result: %f ", side(x)); return 0; }
3、
#include <stdio.h> #include <math.h> int main(void) { double area, side; puts("please input the area."); printf("area = "); scanf("%lf", &area); side = pow(area, 0.5); printf("result: %f ", side); return 0; }
4、
#include <stdio.h> #include <math.h> int main(void) { double area, side; puts("please input the area."); printf("area = "); scanf("%lf", &area); side = pow(area, (double)1/2); printf("result: %f ", side); return 0; }
5、
#include <stdio.h> #include <math.h> int main(void) { double a, b; puts("please input an double value."); printf("a = "); scanf("%lf", &a); b = pow(a, (double)1/3); printf("result: %f ", b); return 0; }