WCM Forum

WCM Forum (http://www.wcm.at/forum/index.php)
-   Programmierung (http://www.wcm.at/forum/forumdisplay.php?f=17)
-   -   Probs mit 'case' und 'switch' in C++ (http://www.wcm.at/forum/showthread.php?t=112876)

Biri 21.10.2003 22:14

jetzt jammer net so viel herum !
debuggen bringt weit mehr wie jammern. :)

sind aber auch logische fehler im prog. - denke, so sollte es funktionieren (ob die formel stimmt, weiß ich net):

PHP-Code:

#include <iostream.h>
#include <math.h>

int main() 
{
    
char s;
    
double p=0q=0x1=0x2=0w=0;
    
bool E=0;

    do
    {
        
cout << endl << "Enter Coefficients by pressing e" << endl
        
cout << "To Compute enter c" << endl;
        
cout << "press x to exit" << endl;

        
cout << "Wahl:";
        
cin  >> s;

        switch(
s)
        {
            case 
'e':                 
                
cout << endl << "Wert fuer p:";
                
cin >> p;
                
cout << "Wert fuer q:";
                
cin >> q;
                break;

            case 
'c':                 
                
w=sqrt(pow((p/2), 2)-q);
                
x1=-p/2+w;
                
x2=-p/2-w;
                if(
p<=0)
                {
                    
cout << "x1=" << -<< "/2+i*" << w;
                    
cout << "x2=" << -<< "/2+i*" << w;
                }
                else
                    
cout << "x1=" << x1 << " and " << "x2=" << x2
                break;
                
            case 
'x':
                
E=1;
                break;
        } 
    } while (
!= 1);
    
    return 
0;



Groovy 21.10.2003 22:32

Danke vielmals! Du hast mir echt weitergeholfen. :)

Biri 22.10.2003 22:51

keine ursache - das war meine "gute tat" zum gestrigen tag. :)

fg
-hannes


Alle Zeitangaben in WEZ +2. Es ist jetzt 09:50 Uhr.

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