Aufgaben und Übungen, 00001

Benutzeravatar
davidvajda.de
Site Admin
Beiträge: 1424
Registriert: Di Jul 18, 2023 8:36 pm
Wohnort: D-72072, Tübingen
Kontaktdaten:

Re: 00001

Beitrag von davidvajda.de »

Code: Alles auswählen

#include <stdio.h>
int f1 (int x4, int x3, int x2, int x1) {
    return ((!x4 && x3 && !x2 && x1) || (!x4 && x3 && x2 && x1) || (x4 && !x3 && !x2 && x1) || (x4 && !x3 && x2 && x1) || (x4 && x3 && !x2 && x1)  || (x4 && x3 && x2 && !x1) | (x4 && x3 && x2 && x1));
}
int f2 (int x4, int x3, int x2, int x1) {
    return ((x3 && x1) || (x4 && x1) || (x4 && x3 && x2));
}
int main (void) {
    int x1;
    int x2;
    int x3;
    int x4;
    for (x4 = 0;  x4 < 2; x4++) {
        for (x3 = 0;  x3 < 2;  x3++) {
            for (x2 = 0;  x2 < 2;  x2++) {
                for (x1 = 0;  x1 < 2;  x1++) {
                    printf ("%i %i %i %i | %i %i\n", x4, x3, x2, x1, f1(x4, x3, x2, x1), f2(x4, x3, x2, x1)); 
                }
            }
        }
    }
}
Antworten