Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#118 Wrong Result without a cout << endl!!!

OTHER
closed
Earnie Boyd
None
out-of-date
No_User_Response
2013-01-27
2002-03-11
Michael K
No

Sorry for my bad English but im from Germany.
I dont know why this BUG(?) appear. First I had a
debug text where the cout << endl; stoods. But when I
was ready with the programm I delet this text and
suddenly ther were wrong REsults. Is this a BUG?

#include<iostream>
#include<iomanip>
#include"mymath.h"
using namespace std;

#define LEN 3

int main()
{
double matrix[LEN][LEN] = {{-4,3,-2},{5,4,-6},
{-3,2,4}}, // matrix initialisieren
rechteSeite[LEN] = {8,-
8,19}, // ergebnisse der
Therme
d
[LEN+1];
// ergebnisse von Dx/D (Cramer'sche Regel)

// Ausgabe der Therme:
for(int i = 0; i < LEN; ++i)
{
cout << i+1 << ": ";
for(int j = 0; j < LEN; ++j)
{
cout << "(" << setw(5) << matrix[i][j]
<< ")" << (char)(97 + i);
if(j != LEN-1) cout << " + ";
}
cout << " = " << rechteSeite[i] << endl;
}
cout << endl;

// Berechnung der Determinanten:
d[0] = determ(*matrix, LEN);
for(int i = 0; i < LEN; ++i) // alle
Determinanten ausrechnen
{
double determinante[LEN][LEN];
for(int n = 0; n < LEN; ++n)
{
for(int m = 0; m < LEN; ++m)
{
if(m == i) determinante[n][m] =
rechteSeite[n];
else determinante[n][m] = matrix[n][m];
}
}
cout << endl; // if i delete this, the
prog write wrong result.
d[i+1] = determ(*determinante, LEN);
}

// Ausgabe der Werte der Determinanten;
for(int i = 0; i < LEN+1; ++i)
cout << "D" << i << " = " << d[i] << endl;

// Ausgabe der Ergebnisse:
cout << "\n\n";
for(int i = 0; i < LEN; ++i)
cout << (char)(97+i) << " = " << (float)d
[i+1] / d[0] << endl;

cin.sync(); cin.clear(); cin.get();
return 0;
}

Discussion

  • Luke Dunstan
    Luke Dunstan
    2002-05-22

    Logged In: YES
    user_id=30442

    I cannot compile this because it uses the "mymath.h" header,
    which is not provided.

     
  • Danny Smith
    Danny Smith
    2002-08-01

    Logged In: YES
    user_id=11494

    No feedback provided {missing header], so cant' see the
    bug. Can you please provide preprocessed source (the
    *.ii file output by --save-temps).

    danny

     
  • Earnie Boyd
    Earnie Boyd
    2002-08-05

    • assigned_to: nobody --> earnie
    • status: open --> closed-out-of-date
     
  • Earnie Boyd
    Earnie Boyd
    2013-01-27

    • status: closed-out-of-date --> closed
    • resolution: --> out-of-date
    • category: --> No_User_Response
    • milestone: --> OTHER