Bedingung falsch
-
Im Teil "Pausenergaenzung" sollen die Takte so aufgefüllt werde, dass sie korrekt sind (Viervierteltakt). So stimmt es auch, aber ich weiß nicht, wie ich die Bedingung setzen muss, dass er aus der zweiten for-Schleife springt.
Hat jemand 'ne Idee?mfG
Phisherman#include <iostream> #include <conio.h> #include <cstdlib> #include <ctime> #include <windows.h> using namespace std; int main() { char Eingabe[1000]="0", Eingabe_fixed[1000]="0"; int bpm, checksum, checkvar=0, checkindex=0; int frequenz=500; cout<<"Befehle:\n\n\n"; cout<<"Ganze Note\t1\n"; cout<<"Halbe Note\t2\n"; cout<<"Viertel Note\t4\n"; cout<<"Achtel Note\t8\n"; cout<<"Ganze Pause\tp\n"; cout<<"Halbe Pause\th\n"; cout<<"Viertel Pause\tv\n"; cout<<"Achtel Pause\ta\n"; cout<<"Metronom\tm\n\n\n\n"; cout<<"Rhythmus eingeben: "; cin.getline (Eingabe, sizeof(Eingabe)); cout<<"Schl"<<char(132)<<"ge pro Minute: "; cin>>bpm; //**Pausenergaenzung************************************************************ for (checkvar; Eingabe[checkvar]!='\0' && Eingabe[checkvar]!='0'; ++checkvar) { checksum=0; for (int j=checkvar; Eingabe[j]!=' ' || Eingabe[j]!='\0' || Eingabe[j]!='0'; ++j) { switch(Eingabe[j]) { case '1': //ganze Note { checksum+=8; Eingabe_fixed[checkindex]='1'; break; } case '2': //halbe Note { checksum+=4; Eingabe_fixed[checkindex]='2'; break; } case '4': //Viertelnote { checksum+=2; Eingabe_fixed[checkindex]='4'; break; } case '8': //Achtelnote { checksum+=1; Eingabe_fixed[checkindex]='8'; break; } case 'g': //ganze Pause { checksum+=8; Eingabe_fixed[checkindex]='g'; break; } case 'h': //halbe Pause { checksum+=4; Eingabe_fixed[checkindex]='h'; break; } case 'v': //Viertelpause { checksum+=2; Eingabe_fixed[checkindex]='v'; break; } case 'a': //Achtel Pause { checksum+=1; Eingabe_fixed[checkindex]='a'; break; } } ++checkindex; if (Eingabe[j+1]==' ' || Eingabe[j+1]=='\0' || Eingabe[j+1]=='0') //Pruefen, ob Takt endet { if (checksum!=8) { while (checksum>8) checksum-=8; switch (checksum) { case 0: { Eingabe_fixed[checkindex]='h'; Eingabe_fixed[checkindex+1]='h'; checkindex+=2; break; } case 1: { Eingabe_fixed[checkindex]='h'; Eingabe_fixed[checkindex+1]='v'; Eingabe_fixed[checkindex+2]='a'; checkindex+=3; break; } case 2: { Eingabe_fixed[checkindex]='h'; Eingabe_fixed[checkindex+1]='v'; checkindex+=2; break; } case 3: { Eingabe_fixed[checkindex]='h'; Eingabe_fixed[checkindex+1]='v'; checkindex+=2; break; } case 4: { Eingabe_fixed[checkindex]='h'; checkindex+=1; break; } case 5: { Eingabe_fixed[checkindex]='v'; Eingabe_fixed[checkindex+1]='a'; checkindex+=2; break; } case 6: { Eingabe_fixed[checkindex]='v'; checkindex+=1; break; } case 7: { Eingabe_fixed[checkindex]='a'; checkindex+=1; break; } } } checkvar=j+1; } } } //**Ende Pausenergaenzung******************************************************* for (int i=0; Eingabe_fixed[i]!='\0'; ++i) { switch(Eingabe[i]) { case '1': //ganze Note { cout<<"X......."; Beep(frequenz, 240000/bpm); break; } case '2': //halbe Note { cout<<"X..."; Beep(frequenz, 120000/bpm); break; } case '4': //Viertelnote { cout<<"X."; Beep(frequenz, 60000/bpm); break; } case '8': //Achtelnote { cout<<"X"; Beep(frequenz, 30000/bpm); break; } case 'g': //ganze Pause { cout<<"g"; Sleep(240000/bpm); break; } case 'h': //halbe Pause { cout<<"v"; Sleep(120000/bpm); break; } case 'v': //Viertelpause { cout<<"v"; Sleep(60000/bpm); break; } case 'a': //Achtel Pause { cout<<"a"; Sleep(30000/bpm); break; } case 'm': // metronom { cout<<"Metronom..."; while (1) { Beep(frequenz+500,60000/bpm); Beep(frequenz,60000/bpm); Beep(frequenz,60000/bpm); Beep(frequenz,60000/bpm); } } } } getch(); }
-
Keine Ahung, was du genau meinst, aber du kannst ja mal Funktionen benutzen, um das ganze ein wenig logisch zu gliedern und bei Funktionen kannst du ganz bequem mit return rausspringen.
-
Die Bedingung verwendet den falschen Operator:
Eingabe[j]!=' ' && Eingabe[j]!='\0' && Eingabe[j]!='0'