1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#include <cstdio>
int main (){
char c;
char d;
int a = 1234;
float f = 3.141592653589;
double x = 0.12345678987654321;
c = '\x41';//十六进制
d = '\101';//八进制
printf("a = %d\n", a);
printf("a = %6d\n", a);
printf("a = %2d\n", a);
printf("a = %-6d--\n", a);
printf("a = %06d\n", a);
printf("a = %02d\n", a);
printf("f = %f\n", f);
printf("f = %6.4f\n", f);
printf("x = %lf\n", x);
printf("x = %18.16lf\n", x);
printf("c = %c\n", c);
printf("c = %d\n", c);
printf("c = %x\n", c);
printf("d = %c\n", d);
printf("d = %d\n", d);
printf("d = %x\n", d);
return 0;
}
|