fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. int ReadInt(int,int,char*);
  6. int Menue(void);
  7. int HornerSchema(int*,int, int);
  8. void HornerFeldEinlesen(int*,int);
  9. void Message(char*,int);
  10. //------------------------------------------------------------------------------------------
  11. // Hauptfunktion: Einstiegspunkt
  12. int main()
  13. {
  14. while(Menue());
  15. return 0;
  16. }
  17. //------------------------------------------------------------------------------------------
  18. int Menue()
  19. {
  20. int Wahl=0;
  21. printf("\n\n\tAbschlusspruefung Informatik");
  22. printf("\n\n\tHorner Schema..............1");
  23. printf("\n\n\tFibonacci..................2");
  24. Wahl=ReadInt(0,3,"\n\nBitte waehlen:");
  25. switch(Wahl)
  26. {
  27. case 1:
  28. {
  29. int feld[1000]; /* das sollte reichen */
  30. int n = ReadInt(0,6,"\n\n\tPolynomgrad:");
  31. int wert = ReadInt(-10,10,"\n\n\tX-Wert:");
  32. printf("\n\n %s","\tHornerschema");
  33. HornerFeldEinlesen(feld,n);
  34. printf("\n\n\tX-Wert %i",HornerSchema(feld, n, wert));
  35. break;
  36. }
  37. case 2:
  38. {
  39. }
  40.  
  41. }
  42. Message("\n\n\tWeiter mit beliebiger Taste....",1);
  43. return (Wahl);
  44. }
  45. //-------------------------------------------------------------------------------------------
  46. int HornerSchema(int*HornerFeld, int N,int Wert)
  47. {
  48. int i;
  49. int r = 0;
  50.  
  51. for(i=N-1; i >= 0; i--)
  52. {
  53. r = r * Wert + HornerFeld[i];
  54. }
  55. return r;
  56. }
  57. //-------------------------------------------------------------------------------------------
  58. void HornerFeldEinlesen(int*HornerFeld, int n)
  59. {
  60. printf("\n\n\n");
  61. while(n--)
  62. {
  63. printf("\n%d.Wert: ",n+1);
  64. scanf("%d",&HornerFeld[n]);
  65. }
  66. }
  67. //-------------------------------------------------------------------------------------------
  68. void Message(char*Text,int Stop)
  69. {
  70. while(getchar()!='\n');
  71. if(Text)
  72. printf(Text);
  73. if(Stop==1)
  74. }
  75. //-------------------------------------------------------------------------------------------
  76. int ReadInt(int UG,int OG,char *Text)
  77. {
  78. int IZahl;
  79. do
  80. {
  81. printf("\n %s( %d...%d) ",Text,UG,OG);
  82. scanf("%d",&IZahl);
  83. if ((IZahl<UG)||(IZahl>OG))
  84. printf("\a\n");
  85. }
  86. while((IZahl<UG)||(IZahl>OG));
  87. return (IZahl);
  88. }
  89.  
Success #stdin #stdout 0s 2296KB
stdin
1
4
3
9
8
7
6

0
stdout

	Abschlusspruefung Informatik

	Horner Schema..............1

	Fibonacci..................2
 

Bitte waehlen:( 0...3) 
 

	Polynomgrad:( 0...6) 
 

	X-Wert:( -10...10) 

 	Hornerschema



4.Wert: 
3.Wert: 
2.Wert: 
1.Wert: 

	X-Wert 342

	Weiter mit beliebiger Taste....

	Abschlusspruefung Informatik

	Horner Schema..............1

	Fibonacci..................2
 

Bitte waehlen:( 0...3) 

	Weiter mit beliebiger Taste....