If....Vergleichbaren Befehl
-
So danke Swordfish, mit der Schleife in der main hab ich nicht verstanden um das programm wieder zu starten . . .. .
Beispeil bitteherzlichen dank
-
Da du ja anscheinend eine Komplettlösung suchst: Beschreib mal den geplanten Programmverlauf, dann bekommst du dein Beispiel maßgeschneidert.
-
Pratwa schrieb:
So danke Swordfish, mit der Schleife in der main hab ich nicht verstanden um das programm wieder zu starten . . .. .
Beispeil bitteherzlichen dank
do { Was immer du auch für Code brauchst um deine Werte einzulesen bitte hierhin if( /* ... */ ) { /* ... */ } else if( /* ... */ ) { /* ... */ } else { /* ... */ } } while (1);
-
ok, Beispiel:
#include <cstdlib> #include <iostream> using namespace std; int main(int argc, char *argv[]) { if( /* ... */ ) { /* ... */ } else if( /* ... */ ) { /* ... */ } else if( /* ... */ ) { /* ... */ } else if( /* ... */ ) { /* ... */ } system("Pause"; return 0; }
-
Pratwa schrieb:
ok, Beispiel:
#include <cstdlib> #include <iostream>
Falsche Sprache. Hier ist C
-
ja sry..
#include <cstdlib> #include <iostream> using namespace std; int main(int argc, char *argv[]) { int ki, kd; scanf("%d",&ki); scanf("%d",&kd); if( /* ... */ ) { /* ... */ } else if( /* ... */ ) { /* ... */ } else if( /* ... */ ) { /* ... */ } else if( /* ... */ ) { /* ... */ } system("Pause"; return 0;
-
#include <stdlib> #include <stdio> int main( void ) { int ki = 0; int kd = 0; if( scanf( "%d", &ki ) != 1 ) { /* Fehlerhafte Eingabe */ return EXIT_FAILURE; } if( scanf( "%d", &kd ) != 1 ) { /* Fehlerhafte Eingabe */ return EXIT_FAILURE; } do { if( /* ... */ ) { /* ... */ } else if( /* ... */ ) { /* ... */ } else if( /* ... */ ) { /* ... */ } else if( /* ... */ ) { /* ... */ } } while( 1 ); }
-
Herzlichen Dank an Alle!
Gelöst...
-
Hmm,
ich wollte es so haben:
scanf("%d",&ki);
scanf("%d",&kd);Das heisst man gibt 2 unterschiedliche Werte ein, diese sollen auch so berücksichtigt werden.
Dann
.
.
.if((ki==4,5) && (kd==2,3) {
printf("True\n");
} else if((ki==1,6) && (kd==9,11){
printf("False\n");
.
.
.Dass heisst.... man gibt 2 Werte am Anfang ein und in jeder Bedinung steht eine andere Kombination (kd,ki).
Z.B.
ki==4,5 && kd==2,3 -> True
ki==1,6 && kd==1,3 -> False
ki==0 && kd==23,44,45 -> FalseKann das so wer lösen, von Zeile 1 ab (also ab inlcude :)) ?
-
#include <stdlib> #include <stdio> int main( void ) { int ki = 0; int kd = 0; if( scanf( "%d", &ki ) != 1 ) { /* Fehlerhafte Eingabe */ return EXIT_FAILURE; } if( scanf( "%d", &kd ) != 1 ) { /* Fehlerhafte Eingabe */ return EXIT_FAILURE; } do { if( ( ki == 4 | ki == 5 ) && ( kd == 2 || kd == 3 ) ) { /* ... */ } else if( ( ki == 1 || ki == 6 ) && ( kd == 1 || kd == 3 ) ) { /* ... */ } else if( !ki && ( kd == 23 || kd == 44 || kd == 45 ) ) { /* ... */ } /* what */ else /* ? */ { /* ... */ } } while( 1 ); }
-
da ist leider ein fehler, wenn es so z.B. ist
Eingabe war kd 23 und kd 45
.. } else if( !ki && ( kd == 23 || kd == 44 || kd == 45 ) ) { printf("true\n"); ..
schreibt er "unedliche" male true, ich wollte aber nur das das programm von neuem mit scanf anfängt und nicht true immer wieder wiederholt...
-
Edit ki23 nicht kd...
-
#include <stdlib> #include <stdio> int main( void ) { int ki = 0; int kd = 0; do { if( scanf( "%d", &ki ) != 1 ) { /* Fehlerhafte Eingabe */ return EXIT_FAILURE; } if( scanf( "%d", &kd ) != 1 ) { /* Fehlerhafte Eingabe */ return EXIT_FAILURE; } if( ( ki == 4 | ki == 5 ) && ( kd == 2 || kd == 3 ) ) { /* ... */ } else if( ( ki == 1 || ki == 6 ) && ( kd == 1 || kd == 3 ) ) { /* ... */ } else if( !ki && ( kd == 23 || kd == 44 || kd == 45 ) ) { /* ... */ } /* what */ else /* ? */ { /* ... */ } } while( 1 ); }
Möchtest du vielleicht irgedwas auch selbst machen?