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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>

int main(int argc, char* argv[]) {
    // OK to use/adapt the concepts used in this file.  If there is truly one and only
    // one way to express that concept, there is no problem if your code ends up being
    // the same, but focus on the concepts and write the code youreslf.  The set of
    // concepts here is probably not quite enough to test comprehensively.

    // EASY CASES
    print_integer(5, 10, "");
    print_integer(-5, 10, "");
    print_integer(-5, 10, "$");

    // "EDGE" CASES
    //
    // Concept:  largest/smallest int;  also try other bases
    print_integer(INT_MAX, 10, "");
    print_integer(INT_MIN, 10, "");
    //
    // Concept:  largest/smallest radix; also try other values of n
    print_integer(768336, 2, "");
    print_integer(768336, 36, "");
    //
    // Concept:  longest(-ish)/shortest prefix
    print_integer(768336, 10, "abc");  // long enough to believe that one more would not
                                       // not change anything.
    print_integer(768336, 10, ""); // shortest
    
    // "CORNER" CASES
    print_integer(0, 10, "");
    print_integer(5, 10, "0");
    print_integer(10, 11, "");  // should print "a"

    // SPECIAL CASES
    // not sure for HW02, but mintf("%z") or mintf("%") would be good for HW05.
    
    return EXIT_SUCCESS;
}
/* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */

© Copyright 2022 Alexander J. Quinn         This content is protected and may not be shared, uploaded, or distributed.