Skip to content
Snippets Groups Projects
Commit 411f20bc authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Musterlösungen zu Aufgabe 4 der Klausur vom 12.2.2018

parent 698e37b1
No related branches found
No related tags found
No related merge requests found
#include <stdio.h>
#include "aufgabe-4.xbm"
int main (void)
{
return 0;
}
#include <stdio.h>
#include <stdint.h>
#include "aufgabe-4.xbm"
int main (void)
{
int aufgabe_4_bytes = (aufgabe_4_width + 7) / 8;
for (int y = 0; y < aufgabe_4_height; y++)
{
for (int b = 0; b < aufgabe_4_bytes; b++)
{
uint8_t buffer = aufgabe_4_bits[y * aufgabe_4_bytes + b];
for (int i = 0; i < 8; i++)
if (buffer & (1 << i))
printf ("*");
else
printf (" ");
}
printf ("\n");
}
return 0;
}
#include <stdio.h>
#include <stdint.h>
#include "aufgabe-4.xbm"
int main (void)
{
// PBM-Datei zum Schreiben öffnen und Vorspann hineinschreiben
FILE *pbm_file = fopen ("test.pbm", "w");
// TODO: Prüfen, ob das Öffnen der Datei geklappt hat, sonst Fehlermeldung!
fprintf (pbm_file, "P4\n%d %d\n", aufgabe_4_width, aufgabe_4_height);
int aufgabe_4_bytes = (aufgabe_4_width + 7) / 8;
for (int y = 0; y < aufgabe_4_height; y++)
{
for (int b = 0; b < aufgabe_4_bytes; b++)
{
uint8_t buffer = aufgabe_4_bits[y * aufgabe_4_bytes + b];
fprintf (pbm_file, "%c", buffer);
}
}
fclose (pbm_file);
return 0;
}
#include <stdio.h>
#include <stdint.h>
#include "aufgabe-4.xbm"
int main (void)
{
// PBM-Datei zum Schreiben öffnen und Vorspann hineinschreiben
FILE *pbm_file = fopen ("test.pbm", "w");
// TODO: Prüfen, ob das Öffnen der Datei geklappt hat, sonst Fehlermeldung!
fprintf (pbm_file, "P4\n%d %d\n", aufgabe_4_width, aufgabe_4_height);
int aufgabe_4_bytes = (aufgabe_4_width + 7) / 8;
for (int y = 0; y < aufgabe_4_height; y++)
{
for (int b = 0; b < aufgabe_4_bytes; b++)
{
uint8_t buffer_xbm = aufgabe_4_bits[y * aufgabe_4_bytes + b];
uint8_t buffer_pbm = 0;
for (int i = 0; i < 8; i++)
if (buffer_xbm & (1 << i))
buffer_pbm |= 1 >> i;
fprintf (pbm_file, "%c", buffer_pbm);
}
}
fclose (pbm_file);
return 0;
}
#include <stdio.h>
#include <stdint.h>
#include "aufgabe-4.xbm"
int main (void)
{
// PBM-Datei zum Schreiben öffnen und Vorspann hineinschreiben
FILE *pbm_file = fopen ("test.pbm", "w");
// TODO: Prüfen, ob das Öffnen der Datei geklappt hat, sonst Fehlermeldung!
fprintf (pbm_file, "P4\n%d %d\n", aufgabe_4_width, aufgabe_4_height);
int aufgabe_4_bytes = (aufgabe_4_width + 7) / 8;
for (int y = 0; y < aufgabe_4_height; y++)
{
for (int b = 0; b < aufgabe_4_bytes; b++)
{
uint8_t buffer_xbm = aufgabe_4_bits[y * aufgabe_4_bytes + b];
uint8_t buffer_pbm = 0;
for (int i = 0; i < 8; i++)
if (buffer_xbm & (1 << i))
buffer_pbm |= 0x80 >> i;
fprintf (pbm_file, "%c", buffer_pbm);
}
}
fclose (pbm_file);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment