Compare commits
2 Commits
8e1ee26b64
...
cd24bbb820
Author | SHA1 | Date | |
---|---|---|---|
cd24bbb820 | |||
11e99475eb |
19
c04_string/floats.c
Normal file
19
c04_string/floats.c
Normal 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
14
c04_string/width.c
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user