9 February 2002







Sample answer for problem 2

#include <stdio.h>

int main(void) {
    char c;
    while (scanf("%c", &c) == 1)
        printf("%c", c);
    return 0;
}

Sample answer for problem 3

#include <stdio.h>

int main(void) {
    int x;
    while (scanf("%d", &x) == 1)
        printf("%x\n", x);
    return 0;
}

Sample answer for problem 4

#include <stdio.h>

int main(void) {
    int x;
    while (scanf("%x", &x) == 1)
        printf("%o\n", x);
    return 0;
}

Sample answer for problem 5

#include <stdio.h>

int main(void) {
    int x;
    while (scanf("%d", &x) == 1)
        printf("%010d\n", x);
    return 0;
}

Sample answer for problem 6

#include <stdio.h>

int main(void) {
    int w = 0;
    char c;
    while (scanf("%c", &c) == 1)
        if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z') {
            scanf("%*[a-zA-Z]");
            w++;
        }
        else if (c == '\n') {
            printf("%d\n", w);
            w = 0;
        }
    return 0;
}

Sample answer for problem 7

#include <stdio.h>

int main(void) {
    unsigned char c;
    while (scanf("%c", &c) == 1)
        printf("%d\n", c);
    return 0;
}

Sample answer for problem 8

#include <stdio.h>

int main(void) {
    unsigned char c;
    while (scanf("%c", &c) == 1)
        printf("%X\n", c);
    return 0;
}

Sample answer for problem 9

#include <stdio.h>

int main(void) {
    unsigned char c[16];
    int i, j = 0;
    while (scanf("%c", &c[j]) == 1) {
        j++;
        if (j == 16) {
            printf("%02x", c[0]);
            for (i = 1; i < j; i++)
                printf(" %02x", c[i]);
            printf("\n");
            j = 0;
        }
    }
    if (j) {
        printf("%02x", c[0]);
        for (i = 1; i < j; i++)
            printf(" %02x", c[i]);
        printf("\n");
    }
    return 0;
}

Sample answer for problem 10

#include <stdio.h>

int main(void) {
    double x;
    while (scanf("%lf", &x) == 1)
        printf("%10.2f\n", x);
    return 0;
}