Quantcast
Channel: SPS-Forum - Automatisierung und Elektrotechnik
Viewing all articles
Browse latest Browse all 49376

TC2: Überprüfen, ob nur ein Eingang gesetzt ist.

$
0
0
Hallo,
ich stehe gerade auf dem Schlauch.
Eine beliebige Anzahl boolscher Werte soll dahingehend überprüft werden, ob nur einer gesetzt ist. Meine Lösung wäre:

Code:

Ergebnis := (Eing1 OR Eing2 OR Eing3 … OR EingX) AND
(
(Eing1 AND NOT Eing2 AND NOT Eing3 … AND NOT EingX)
OR
(NOT Eing1 AND Eing2 AND NOT Eing3 … AND NOT EingX)
OR
(NOT Eing1 AND NOT Eing2 AND Eing3 … AND NOT EingX)
...
OR

(NOT Eing1 AND NOT Eing2 AND NOT Eing3 … AND EingX)
)

Aber das geht doch sicher einfacher/eleganter, oder? Nur wie?

Gruß

Oliver

Viewing all articles
Browse latest Browse all 49376


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>