Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hallgrim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan Maximilian Michal
hallgrim
Commits
3e5f2a28
Commit
3e5f2a28
authored
8 years ago
by
Jan Maximilian Michal
Browse files
Options
Downloads
Patches
Plain Diff
Polyonme script added
parent
918fb26b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/Polynome (I1-ID: 177d1ez05pg0).py
+75
-0
75 additions, 0 deletions
scripts/Polynome (I1-ID: 177d1ez05pg0).py
with
75 additions
and
0 deletions
scripts/Polynome (I1-ID: 177d1ez05pg0).py
0 → 100644
+
75
−
0
View file @
3e5f2a28
meta
=
{
'
author
'
:
'
Jan Maximilian Michal
'
,
'
title
'
:
'
Polynome (I1-ID: 177d1ez05pg0)
'
,
'
type
'
:
'
gap
'
,
'
points
'
:
0.0
,
}
task
=
"""
Vervollständigen Sie die folgende Klasse:
```java
public class Polynom {
// diese Klasse dient dazu, Polynome (also Funktionen der Gestalt
// a(x) = a0 + a1*x + a2*x^2 + ... + ad*x^d) als statische
// Java-Funktionen bereitzustellen
/* Argumente: double-Feld (fuer Koeffizienten a0, a1, .., ad) und Zahl x
Ergebniswert: Wert des Polynoms an der Stelle x (Typ double)*/
public static double p([gap(0.5P)]double[] a[/gap], double x) {
// Sonderfall: das Nullpolynom
int d = [gap(0.5P)]a.length - 1[/gap]; // Polynomgrad
if ( d == -1)
return 0;
// ansonsten: berechne gesuchten Wert nach dem Horner-Schema:
double v = 0;
for (int i = d; i [gap(0.5P)]>=[/gap] 0; i--) {
v [gap(0.5P)]*=[/gap] x;
v += a[i];
}
return v;
}
public static void main(String[] args) { /* Unit-Test */
[gap(0.5P)]double[][/gap] a = {2,1,-1,3};
System.out.println(p([gap(0.5P)]a[/gap], 10));
}
}
```
Welcher Wert wird bei dem Unit-Test ausgegeben? [gap(1P)]2912[/gap]
"""
feedback
=
"""
Der vollständige Quelltext
```java
public class Polynom {
// diese Klasse dient dazu, Polynome (also Funktionen der Gestalt
// a(x) = a0 + a1*x + a2*x^2 + ... + ad*x^d) als statische
// Java-Funktionen bereitzustellen
/* Argumente: double-Feld (fuer Koeffizienten a0, a1, .., ad) und Zahl x
Ergebniswert: Wert des Polynoms an der Stelle x (Typ double)*/
public static double p(double[] a, double x) {
// Sonderfall: das Nullpolynom
int d = a.length - 1; // Polynomgrad
if ( d == -1)
return 0;
// ansonsten: berechne gesuchten Wert nach dem Horner-Schema:
double v = 0;
for (int i = d; i >= 0; i--) {
v *= x;
v += a[i];
}
return v;
}
public static void main(String[] args) { /* Unit-Test */
double[] a = {2,1,-1,3};
System.out.println(p(a, 10));
}
}
```
"""
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment