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

Klausur vom Wintersemester 2015/16: Beispiel-Programme

parent c6cbb7a4
No related branches found
No related tags found
No related merge requests found
#include <stdio.h>
#include <string.h>
void fun (char *s)
{
int len = strlen (s);
for (int i = 0; i < len; i++)
for (int j = i + 1; j < len; j++)
if (s[i] > s[j])
{
char sx = s[i];
s[i] = s[j];
s[j] = sx;
}
}
int main (void)
{
char s[] = "Informatik";
fun (s);
printf ("%s\n", s);
return 0;
}
#include <stdio.h>
#include <string.h>
void fun (char *s)
{
int len = strlen (s);
for (int i = 0; i < len; i++)
for (int j = i + 1; j < len; j++)
if (s[i] > s[j])
{
char sx = s[i];
s[i] = s[j];
s[j] = sx;
}
}
int main (void)
{
char s[] = { 'I', 'n', 'f', 'o' };
fun (s);
printf ("%s\n", s);
return 0;
}
#include <stdio.h>
#include <stdint.h>
void output (uint16_t *a)
{
for (int i = 0; a[i]; i++)
printf (" %d", a[i]);
printf ("\n");
}
int main (void)
{
uint16_t prime_numbers[] = { 2, 3, 5, 7, 11, 13, 17, 0 };
uint16_t *p1 = prime_numbers;
output (p1);
p1++;
output (p1);
char *p2 = prime_numbers;
output (p2);
p2++;
output (p2);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
char symbol;
int (*calculate) (int a, int b);
}
operation;
operation *new_operation (void)
{
operation *op = malloc (sizeof (operation));
op->symbol = '?';
op->calculate = NULL;
return op;
}
[...]
int main (void)
{
operation *op[4];
op[0] = new_plus ();
op[1] = new_minus ();
op[2] = new_times ();
op[3] = NULL;
for (int i = 0; op[i]; i++)
printf ("2 %c 3 = %d\n", op[i]->symbol, op[i]->calculate (2, 3));
return 0;
}
20170130/aufgabe-4.png

162 B

#define aufgabe_4_width 14
#define aufgabe_4_height 14
static unsigned char aufgabe_4_bits[] = {
0x00, 0x00, 0xf0, 0x03, 0x08, 0x04, 0x04, 0x08, 0x02, 0x10, 0x32, 0x13,
0x22, 0x12, 0x02, 0x10, 0x0a, 0x14, 0x12, 0x12, 0xe4, 0x09, 0x08, 0x04,
0xf0, 0x03, 0x00, 0x00 };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment