编程札记

C

C库函数 exp()

C库函数 exp() #include <stdio.h> #include <math.h> int main () { double x = 0; printf("The exponential value of %lf is %lf\n", x, exp(x)); printf("The exponential value of %lf is %lf\n", x+1, exp(x+1)); printf("The exponential value of %lf is %lf\n", x+2, exp(x+2)); return(0); }

阅读全文 ↗
C

C库函数 tanh()

C库函数 tanh() #include <stdio.h> #include <math.h> int main () { double x, ret; x = 0.5; ret = tanh(x); printf("The hyperbolic tangent of %lf is %lf degrees", x, ret); return(0); }

阅读全文 ↗
C

C库函数 sinh()

C库函数 sinh() #include <stdio.h> #include <math.h> int main () { double x, ret; x = 0.5; ret = sinh(x); printf("The hyperbolic sine of %lf is %lf degrees", x, ret); return(0); }

阅读全文 ↗
C

C库函数 sin()

C库函数 sin() #include <stdio.h> #include <math.h> #define PI 3.14159265 int main () { double x, ret, val; x = 45.0; val = PI / 180; ret = sin(x*val); printf("The sine of %lf is %lf degrees", x, ret); return(0); }

阅读全文 ↗
C

C库函数 cosh()

C库函数 cosh() #include <stdio.h> #include <math.h> int main () { double x; x = 0.5; printf("The hyperbolic cosine of %lf is %lf\n", x, cosh(x)); x = 1.0; printf("The hyperbolic cosine of %lf is %lf\n", x, cosh(x)); x = 1.5; printf("The hyperbolic cosine of %lf is %lf\n", x, cosh(x)); return(0); }

阅读全文 ↗
C

C库函数 cos()

C库函数 cos() #include <stdio.h> #include <math.h> #define PI 3.14159265 int main () { double x, ret, val; x = 60.0; val = PI / 180.0; ret = cos( x*val ); printf("The cosine of %lf is %lf degrees\n", x, ret); x = 90.0; val = PI / 180.0; ret = cos( x*val ); printf("The cosine of %lf is %lf degrees\n", x, ret); return(0); }

阅读全文 ↗
C

C库函数 atan2()

C库函数 atan2() #include <stdio.h> #include <math.h> #define PI 3.14159265 int main () { double x, y, ret, val; x = -7.0; y = 7.0; val = 180.0 / PI; ret = atan2 (y,x) * val; printf("The arc tangent of x = %lf, y = %lf ", x, y); printf("is %lf degrees\n", ret); return(0); }

阅读全文 ↗
C

C库函数 atan()

C库函数 atan() #include <stdio.h> #include <math.h> #define PI 3.14159265 int main () { double x, ret, val; x = 1.0; val = 180.0 / PI; ret = atan (x) * val; printf("The arc tangent of %lf is %lf degrees", x, ret); return(0); }

阅读全文 ↗
C

C库函数 asin()

C库函数 asin() #include <stdio.h> #include <math.h> #define PI 3.14159265 int main () { double x, ret, val; x = 0.9; val = 180.0 / PI; ret = asin(x) * val; printf("The arc sine of %lf is %lf degrees", x, ret); return(0); }

阅读全文 ↗
C

C库函数 acos()

C库函数 acos() #include <stdio.h> #include <math.h> #define PI 3.14159265 int main () { double x, ret, val; x = 0.9; val = 180.0 / PI; ret = acos(x) * val; printf("The arc cosine of %lf is %lf degrees", x, ret); return(0); }

阅读全文 ↗
C

C库函数 localeconv()

C库函数 localeconv() #include <locale.h> #include <stdio.h> int main () { struct lconv * lc; setlocale(LC_MONETARY, "it_IT"); lc = localeconv(); printf("Local Currency Symbol: %s\n",lc->currency_symbol); printf("International Currency Symbol: %s\n",lc->int_curr_symbol); setlocale(LC_MONETARY, "en_US"); lc = localeconv(); printf("Local Currency Symbol: %s\n",lc->currency_symbol); printf("International Currency Symbol: %s\n",lc->int_curr_symbol); setlocale(LC_MONETARY, "en_GB"); lc = localeconv(); printf ("Local Currency Symbol: %s\n",lc->currency_symbol); printf ("International Currency Symbol: %s\n",lc->int_curr_symbol); printf("Decimal Point = %s\n", lc->decimal_point); return 0; }

阅读全文 ↗
C

C库函数 setlocale()

C库函数 setlocale() #include <locale.h> #include <stdio.h> #include <time.h> int main () { time_t currtime; struct tm *timer; char buffer[80]; time( &currtime ); timer = localtime( &currtime ); printf("Locale is: %s\n", setlocale(LC_ALL, "en_GB")); strftime(buffer,80,"%c", timer ); printf("Date is: %s\n", buffer); printf("Locale is: %s\n", setlocale(LC_ALL, "de_DE")); strftime(buffer,80,"%c", timer ); printf("Date is: %s\n", buffer); return(0); }

阅读全文 ↗