先看代码:
#include <stdio.h> #define INTDEMO 250 int main() { const double DOUBLEDEMO = 3.14159; const short SHORTDEMO = 0xFFFF; printf("%2d\n",INTDEMO); printf("%10d\n", INTDEMO); printf("%-10d\n",INTDEMO); printf("%f\n", DOUBLEDEMO); printf("%Lf\n", DOUBLEDEMO); printf("%4.2Lf\n", DOUBLEDEMO); printf("%10.3Le\n", DOUBLEDEMO); printf("%10.3Lf\n", DOUBLEDEMO); printf("%010.3Lf\n", DOUBLEDEMO); printf("%+010.3Lf\n", DOUBLEDEMO); printf("%c", SHORTDEMO); float f_num = 3.0; double d_num = 3.0; int i_num = 2000000000; long l_num = 1234567890; printf("%.1g %.1g %.1g %.1g", f_num, d_num, i_num, l_num); printf("%ld %ld", i_num, l_num); printf("%ld %ld %ld %ld", f_num, d_num, i_num, l_num); printf("I""Love", "Mark"); getchar(); return 0; }
运行得出:
时间: 2024-10-30 04:24:41