Einzelnen Beitrag anzeigen
Ungelesen 05.02.12, 17:45   #2
Your_Conscience
Hinter dir!
 
Registriert seit: Apr 2010
Beiträge: 1.125
Bedankt: 487
Your_Conscience ist noch neu hier! | 0 Respekt Punkte
Standard

Code:
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int max1st = INT_MIN, max2nd = INT_MIN, h;
    
    while (1) {
          printf("Bitte Zahl eingeben: ");
          scanf("%d", &h);
          if (h >= max1st) {
             max2nd = max1st;
             max1st = h;
          } else if (h > max2nd) max2nd = h;
          if (max1st > INT_MIN) printf("1. groesste Zahl: %d\n", max1st);
          if (max2nd > INT_MIN) printf("2. groesste Zahl: %d\n", max2nd);
    }

    return EXIT_SUCCESS;
}
Your_Conscience ist offline   Mit Zitat antworten