]> hackdaworld.org Git - my-code/beginners.git/commitdiff
added 3 c progs: fehler.c, histp.c, layout.c
authorhackbard <hackbard>
Thu, 4 Apr 2002 18:04:30 +0000 (18:04 +0000)
committerhackbard <hackbard>
Thu, 4 Apr 2002 18:04:30 +0000 (18:04 +0000)
fehler.c [new file with mode: 0644]
histo.c [new file with mode: 0644]
layout.c [new file with mode: 0644]

diff --git a/fehler.c b/fehler.c
new file mode 100644 (file)
index 0000000..0eaa015
--- /dev/null
+++ b/fehler.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <math.h>
+
+#define VARIABLEN_TYP double
+#define MAX_ 40
+
+main()
+{
+VARIABLEN_TYP erg, x1, x2;
+int i;
+
+x1=30;
+x2=25;
+
+printf("1 Ergebnis: 30");
+printf("2 Ergebnis: 25");
+
+for (i=3;i<=MAX_;++i)
+       {
+       printf("%02d. Ergebnis: %08.2f\texakt: %f\n",i,erg=(-13*x2/6)+(5*x1/2),36.*pow((5./6),i));
+       x1=x2;
+       x2=erg;
+       }
+}
diff --git a/histo.c b/histo.c
new file mode 100644 (file)
index 0000000..927d663
--- /dev/null
+++ b/histo.c
@@ -0,0 +1,27 @@
+#define BREITE 81
+#define HOEHE 24
+#define FUNKTION y=(x-8)*(x-8)-10
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+int x,y,i;
+char z;
+
+int main(void)
+{
+for(i=0;i++<BREITE-1;printf("-")); 
+printf("Histogramm\n");
+for(i=0;i++<BREITE-1;printf("-"));
+
+for(x=0;x<=HOEHE-4;x++)
+       {
+       FUNKTION;
+       (y==0)?(z='0'):((y>0)?(z='+'):(z='-'));
+       printf("%02d",x);
+       if (y>BREITE-3) {y=BREITE-3;z='*';}
+       for(;y-->1;printf(" "));
+       printf("%c\n",z);
+       }
+return(0);
+}
diff --git a/layout.c b/layout.c
new file mode 100644 (file)
index 0000000..5c53c24
--- /dev/null
+++ b/layout.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+#include <math.h>
+
+main()
+{
+
+float x;
+
+printf("  x  |    f(x)  \n__________________\n");
+for (x=0;x<10;x=x+.1)
+       printf(" %3.1f | %010.3f \n",x,x*exp(x));
+}