#include <stdio.h>
#include <stdlib.h>
#include "kadai2.h"

void dellist(ULIST* p) {
    if (p != NULL) {
        dellist(p->next);
        free(p);
    }
}
int main(void) {
    int i;
    int j;
    URIAGE u[] = { {12,3},{1,4},{2,5},{11,6},{0} };
    ULIST* p = malloc(sizeof(ULIST));
    ULIST* q;
    if (p == NULL) {
        exit(1);
    }
    p->next = NULL;
    for (i = 0; u[i].no != 0; i++) {
        q = add(p, u[i]);
        if (q == NULL) {
            dellist(p);
            exit(1);
        }
        printf("売上:");
        printuriage(q->uriage);
        printf("%.2f円\n-----------\n", printuriagelist(p));
    }
    zeiritsu[1] = 0;
    for (j = 0; j < 2; j++) {
        printf("種別: %d\n", j);
        printf("%.2f円\n-----------\n", printuriagelistbyshubetsu(p, j));
    }
    return 0;
}
