while funktioniert nicht
-
// 3Potenzabteiler #include <iostream> #include <string> #include <cmath> using namespace std; int zahl; int pot3; int potenzgrenze=0; int gugzz; //GesamtungeradeZahlZähler int bugz; //BereichsungeradeZahlZähler int xox = 0; int fzeh; int pzz; int teiler=3; int found; int main() { for(zahl=1; zahl<=1000000; zahl=zahl+2) //ungerader Zahlhersteller { if(zahl%5==0) //Fünfzähler { fzeh=fzeh+1; } else // Nur wenn Zahl nicht 5, dann Primprüfung { while ((teiler<=sqrt(zahl)) %% (found == 0)) //Was soll hier die 2. Bedingung? { if ( zahl%teiler==0) { found=1; //Wieso macht er hier faund auf 1 und was ist found? } else { teiler++; //Teiler um 2 erhöhen damit er Ungerade bleibt. teiler++; } if (found==0) // Dann ist Zahl prim { pzz++;// tue hier das, was zu tun ist, wenn der kandidat prim ist cout<<pzz<<" \n"; } } //Ende While } gugzz=gugzz+1; bugz=bugz+1; for (pot3=0; pot3<=15; pot3++) { xox=potenzgrenze; potenzgrenze = pow(3.0,pot3); if (zahl == potenzgrenze) { cout<<"Von "<<xox<<" bis einschl. "<<zahl<<""; //cout<<" =3^"<<pot3<<" "; cout<<" gibt es "<<bugz<<" uZ davon sind "<<fzeh<<" 5en \n"; //cout<<"und insgesamt von 0 an "<<gugzz<<" \n"; bugz=0; fzeh=0; } } } return 0; }Bis zur Implementierung der While-Schleife lief das Teil. Er zählte die ung. Zahlen bis zur Grenze, und die Fünfen. Jetzt wollt ich noch die Primzahlen zählen lassen.... und hab mir die While Schleife geborgt....
Nun sagt der Compiler: "Expected Expression" Was für einen Ausdruck erwartet er?
-
%%Diesen Operator hat nicht mal Perl. Was soll der denn machen?
-
...
-
Swordfish schrieb:
Was soll denn
%%für ein Operator sein?Er hat den Code abgetippt und 5 statt 6 gedrückt, und seinen Post nicht durchgelesen, bevor er ihn abgeschickt hat.
-
Nein das ist aus C ein Operator, ein boolescher ....
oh, das mit der Verwechslung von 5 und 6 stimmt ....
-
Niemals Code abtippen! Benutze Copy&Paste...