First Encounter with ACM — What Is All This -.-

Words: 161

The senior student explains output and data types

The code looks like this:

cpp
 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;
}

I was internally falling apart -.-

But looking at it now, it’s actually not that bad — it was also the first step into exploring C.

This post is licensed under CC BY-NC-SA 4.0. If it helped, or if you have anything to say, the comment box below is open.
Page views —
Unique visitors —

Loading...