WCM Forum

WCM Forum (http://www.wcm.at/forum/index.php)
-   Programmierung (http://www.wcm.at/forum/forumdisplay.php?f=17)
-   -   Compilerfehlermeldung VS 6.0 - Warum (http://www.wcm.at/forum/showthread.php?t=176082)

coolbininet 15.10.2005 14:24

Compilerfehlermeldung VS 6.0 - Warum
 
Hallo Leute!

Prüte über folgendem Problem: Möchte gerne ein Programm in C++ schreiben das Primfaktoren zerlegen soll bekomme aber immer nur eine Fehlermeldung vom Compiler, warum?

Meldung: error C2064: Ausdruck ergibt keine Funktion

Benutze Visual Studio 6.0.

Was geht da nicht, ich seh mich nicht mehr raus!!

Code:

#include <stdio.h>
#include <iostream.h>
// Ergebnis: Wie oft kann man z durch n teilen
// Wenn Ergebnis>0 wird z um n^Ergebnis reduziert.long vielfach (long &z, long n);
void main(void)
{   
        long zahl, hilf, pot, teiler=2, vielfach;   
        cout << "Zahl eingeben : ";   
        cin  >> zahl;    hilf=zahl;     
        while (teiler < zahl/2+1 && hilf>0)   
        {        pot = vielfach (hilf, teiler); // Teiler wird getestet
                if (pot != 0)
                        {
                        cout << teiler << "^" << pot << " "; teiler ++;
                        }
                        cout << endl;
        }

}
long vielfach (long &z, long n)
{   
        long count=0;   
        while (z%n == 0 && z>1 ) // Solange Teilen bis es nicht mehr geht   
        {
                z /= n; count++;   
        }   
        return count;
}

Grüsse Coolbininet

käptn 15.10.2005 17:14

Sollt' das nicht #include <iostream> heißen?

Zeilennummer der Fehlermeldung wär' nicht schlecht... :)

~

pong 15.10.2005 17:46

Zitat:

Meldung: error C2064: Ausdruck ergibt keine Funktion
Zeile?

pong

coolbininet 15.10.2005 19:33

Nochmal geändert!
 
Hallo Leute!

Habe das Progi nochmal geändert. Keine Fehlermeldung mehr, aber im Ergebnis stimmt etwas nicht.

Code:

#include <stdio.h>
#include <iostream.h>
// Ergebnis: Wie oft kann man z durch n teilen
// Wenn Ergebnis>0 wird z um n^Ergebnis reduziert.long vielfach (long &z, long n);
long vielfach (long &z, long n);  // enweder so oder main nach der funk anordnen

void main(void)
{   
        long zahl, hilf, pot, teiler=2;  //, vielfach; --> keine ref auf funk
        //long zahl, hilf, pot, teiler=2, vielfach(long &z, long n); // so gehts auch
        cout << "Zahl eingeben : ";   
        cin  >> zahl;    hilf=zahl;     
        while (teiler < zahl/2+1 && hilf>0)   
        {        pot = vielfach (hilf, teiler); // Teiler wird getestet
                if (pot != 0)
                        {
                        cout << teiler << "^" << pot << " "; teiler ++;
                        }
                        cout << endl;
        }

}
long vielfach (long &z, long n)
{   
        long count=0;   
        while (z%n == 0 && z>1 ) // Solange Teilen bis es nicht mehr geht   
        {
                z /= n; count++;   
        }   
        return count;
}

Jetzt startet alles, aber es klappt werder für die Zahl 8, 84 usw. nur bei 4 habe ich ein Ergbnis, dass nicht richtig ist, aber ein Ergebnis.

Grüsse coolbininet


Alle Zeitangaben in WEZ +2. Es ist jetzt 14:36 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© 2009 FSL Verlag