howto:equispaced_values
no way to compare when less than two revisions
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
— | howto:equispaced_values [2015-06-28 16:55] (aktuell) – angelegt - Externe Bearbeitung 127.0.0.1 | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | ====== Gleichabständige Werte im Intervall [a,b] erzeugen ====== | ||
+ | |||
+ | ===== Aufgabe ===== | ||
+ | Erzeuge in einer Schleife n+1 Werte $x_i$ im Intervall $[a,b]$ eines nichtganzzahligen Grundbereichs D. | ||
+ | |||
+ | ===== handgeschrieben ===== | ||
+ | <code cpp> | ||
+ | auto dx = (b-a)/n; | ||
+ | for (int i = 0; i <= n; ++i) | ||
+ | { | ||
+ | auto x = a + i * dx; | ||
+ | // ... | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== range-based for ===== | ||
+ | mit Headerdatei [[https:// | ||
+ | <code cpp> | ||
+ | #include " | ||
+ | // ... | ||
+ | |||
+ | for (auto x : loop:: | ||
+ | { | ||
+ | // ... | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | mit Bibliothek [[https:// | ||
+ | <code cpp> | ||
+ | #include " | ||
+ | // ... | ||
+ | |||
+ | auto dx = (b-a)/n; | ||
+ | for (auto x : iter:: | ||
+ | { | ||
+ | // ... | ||
+ | } | ||
+ | </ | ||
+ | mit [[http:// | ||
+ | <code cpp> | ||
+ | #include < | ||
+ | #include < | ||
+ | // ... | ||
+ | |||
+ | for (auto x : boost:: | ||
+ | { | ||
+ | // ... | ||
+ | } | ||
+ | </ | ||
+ | |||
howto/equispaced_values.txt · Zuletzt geändert: 2015-06-28 16:55 von 127.0.0.1