Compare commits

..

2 Commits

Author SHA1 Message Date
cd24bbb820 floats.c 2023-12-05 21:04:08 +08:00
11e99475eb width.c 2023-12-05 20:53:38 +08:00
2 changed files with 33 additions and 0 deletions

19
c04_string/floats.c Normal file
View File

@ -0,0 +1,19 @@
/* floats.c - 一些浮点型修饰符的组合 */
#include <stdio.h>
int main(void)
{
const double RENT = 3852.99; // const变量只读变量不是常量
printf("*%f*\n", RENT);
printf("*%e*\n", RENT);
printf("*%4.2f*\n", RENT);
printf("*%3.1f*\n", RENT);
printf("*%10.3f*\n", RENT);
printf("*%10.3E*\n", RENT);
printf("*%+4.2f*\n", RENT);
printf("*%+10.2f*\n", RENT);
printf("*%010.2f*\n", RENT);
return 0;
}

14
c04_string/width.c Normal file
View File

@ -0,0 +1,14 @@
/* width.c - 字段宽度 */
#include <stdio.h>
#define PAGES 959
int main(void)
{
printf("*%d*\n", PAGES);
printf("*%2d*\n", PAGES);
printf("*%10d*\n", PAGES);
printf("*%-10d*\n", PAGES);
return 0;
}