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

Skript und Übersichtsdatei (README.md)

parent c88d1473
Branches
No related tags found
No related merge requests found
Showing with 281 additions and 0 deletions
#include <stdio.h>
typedef struct
{
char day, month;
int year;
}
date;
void set_date (date *d)
{
d->day = 28;
d->month = 2;
d->year = 2000;
}
void inc_date (date *d)
{
d->day++;
int days_in_month = 31;
if (d->month == 2)
{
int is_leap_year = 0;
if (d->year % 4 == 0)
{
is_leap_year = 1;
if (d->year % 100 == 0)
{
is_leap_year = 0;
if (d->year % 400 == 0)
is_leap_year = 1;
}
}
if (is_leap_year)
days_in_month = 29;
else
days_in_month = 28;
}
else if (d->month == 4 || d->month == 6 || d->month == 9 || d->month == 11)
days_in_month = 30;
if (d->day > days_in_month)
{
d->month++;
d->day = 1;
if (d->month > 12)
{
d->year++;
d->month = 1;
}
}
}
int main (void)
{
date today;
set_date (&today);
inc_date (&today);
printf ("%d.%d.%d\n", today.day, today.month, today.year);
return 0;
}
#include <stdio.h>
int main (void)
{
int a;
printf ("Bitte eine Zahl eingeben: ");
scanf ("%d", &a);
printf ("Sie haben eingegeben: %d\n", a);
return 0;
}
#include <stdio.h>
int main (void)
{
int a;
printf ("Bitte eine Zahl eingeben: ");
scanf ("%d", a);
printf ("Sie haben eingegeben: %d\n", a);
return 0;
}
../common/io-ports-and-interrupts.pdf
\ No newline at end of file
../common/logo-hochschule-bochum-cvh-text-v2.pdf
\ No newline at end of file
../common/logo-hochschule-bochum.pdf
\ No newline at end of file
#include <stdio.h>
int main (void)
{
int i = 1;
while (i <= 10)
{
printf ("%d\n", i);
i = i + 1;
}
return 0;
}
#include <stdio.h>
int main (void)
{
int i;
for (i = 1; i <= 10; i = i + 1)
printf ("%d\n", i);
return 0;
}
#include <stdio.h>
int main (void)
{
int i;
for (i = 1; 10; i + 1)
printf ("%d\n", i);
return 0;
}
Vor langer, langer Zeit
gab es einmal
#include "hexe.h"
Die lebte in einem Wald.
#include <stdio.h>
int main (void)
{
printf ("%d\n", 23 + 19);
return 0;
}
../common/moon-texture.png
\ No newline at end of file
#if defined(__APPLE__) || defined(MACOSX)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#endif
#include "opengl-magic.h"
void init_opengl (int *argcp, char **argv, char *window_name)
{
glutInit (argcp, argv);
glutInitDisplayMode (GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize (1024, 768);
glutCreateWindow (window_name);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective (20.0, -1.33333, 3.0, 7.0);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
glTranslatef (0.0, 0.0, -5.0);
glClearColor (0.0, 0.0, 0.0, 0.0);
glEnable (GL_DEPTH_TEST);
glEnable (GL_LIGHTING);
glEnable (GL_LIGHT0);
static GLfloat light0_position[] = { 1.0, 0.0, 1.0, 0.0 };
glLightfv (GL_LIGHT0, GL_POSITION, light0_position);
}
void set_material_color (float r, float g, float b)
{
GLfloat color[] = { r, g, b };
glMaterialfv (GL_FRONT, GL_AMBIENT, color);
glMaterialfv (GL_FRONT, GL_DIFFUSE, color);
}
#if defined(__APPLE__) || defined(MACOSX)
void glutSolidCylinder (double radius, double height, int slices, int stacks)
{
GLUquadricObj *q = gluNewQuadric ();
gluCylinder (q, radius, radius, height, slices, stacks);
gluDeleteQuadric (q);
}
#endif
#ifndef OPENGL_MAGIC_H
#define OPENGL_MAGIC_H
extern void init_opengl (int *argcp, char **argv, char *window_name);
extern void set_material_color (float r, float g, float b);
#ifdef __MACOSX__
extern void glutSolidCylinder (double radius, double height, int slices, int stacks);
#endif
#endif /* OPENGL_MAGIC_H */
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include "opengl-magic.h"
#include "textured-spheres.h"
float t = 0.0;
GLuint earth_texture, moon_texture;
void draw_earth (void)
{
glPushMatrix ();
glRotatef (90, 1.0, 0.0, 0.0);
glRotatef (100.0 * t, 0.0, 0.0, 1.0);
draw_textured_sphere (earth_texture, 0.25512, 63, 20);
glPopMatrix ();
}
void draw_moon (void)
{
glPushMatrix ();
glRotatef (90, 1.0, 0.0, 0.0);
glRotatef (-90, 0.0, 0.0, 1.0);
draw_textured_sphere (moon_texture, 0.06952, 31, 10);
glPopMatrix ();
}
void draw (void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix ();
glRotatef (23.44, 1.0, 0.0, -1.0);
draw_earth ();
glRotatef (5.145, 0.0, 1.0, 1.0);
glRotatef (30.0 * t, 0.0, -1.0, 0.0);
glTranslatef (0.9, 0.0, 0.0);
draw_moon ();
glPopMatrix ();
glFlush ();
glutSwapBuffers ();
}
void timer_handler (int value)
{
t += 0.05;
glutPostRedisplay ();
glutTimerFunc (50, timer_handler, 0);
}
int main (int argc, char **argv)
{
init_opengl (&argc, argv, "Orbit");
init_texture ("earth-texture.png", &earth_texture);
init_texture ("moon-texture.png", &moon_texture);
glutDisplayFunc (draw);
glutTimerFunc (50, timer_handler, 0);
glutMainLoop ();
return 0;
}
#include <stdio.h>
int main (void)
{
printf (42);
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("Die Antwort lautet: %d\n", 42);
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("Richtige Antworten wären %d oder %d oder sonstige.\n", 1, 2);
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("Richtige Antworten wären %d", 1, " oder %d", 2, " oder sonstige.\n");
return 0;
}
#include <stdio.h>
int main (int argc, char **argv)
{
printf ("argc = %d\n", argc);
for (int i = 0; i < argc; i++)
printf ("argv[%d] = \"%s\"\n", i, argv[i]);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment