Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.93 KB | None | 0 0
  1. /* Wiederholtes Einlesen und Berechnen von Temperaturwerten     *
  2.  * Autor: Philipp Heckenmüller                                 *
  3.  * Datum: 27.11.2014                                            */
  4. #define _CRT_SECURE_NO_WARNINGS
  5. #include<stdio.h>
  6. int main(void) {
  7.     double dMaxC = 0, dMinC = 100, dMidC, dSumC = 0, dMaxF = 0, dMinF = 100, dMidF, dSumF = 0, Cel, Fah;
  8.     int iRunde = 0, iGelesen;
  9.  
  10.     do {
  11.         printf("Temperatur in \xF8""Celsius (0 ... 100, Strg + z zum Beenden): ");
  12.  
  13.         iGelesen = scanf("%lf", &Cel);
  14.         fflush(stdin);
  15.  
  16.         if (iGelesen == 0) {
  17.             printf("   Bitte geben Sie eine Zahl ein!\n\n");
  18.         }
  19.         if (iGelesen == -1) {
  20.             printf("   Eingabe beendet\n\nBericht:\n  Es wurden %d  Werte eingegeben:", iRunde);
  21.             printf("\n     Fahrenheit: min = %3.1lf, Mittel = %3.1lf, max = %3.1lf)", dMinF, dMidF, dMaxF);
  22.             printf("\n     Celsius: min = %3.1lf, Mittel = %3.1lf, max = %3.1lf)", dMinC, dMidC, dMaxC);
  23.             printf("\n\n\nBet\x84tigen Sie die Enter-Taste zum Beenden"); //\n\n\nBet\x84tigen Sie die Enter-Taste zum Beenden (dr\x81cken Sie drauf!)...
  24.         }
  25.         if (iGelesen == 1) {
  26.             if (Cel > 100) {
  27.                 printf("Die Zahl ist zu gro\xE1 (%3.1lf > 100)!\n\n", Cel);
  28.             }
  29.  
  30.             if (Cel < 0) {
  31.                 printf("Die Zahl ist zu klein (%3.1lf < 0)!\n\n", Cel);
  32.             }
  33.            
  34.             if (Cel >= 0 && Cel <= 100) {
  35.                 Fah = (Cel * 1.8) + 32;
  36.                 dSumC = dSumC + Cel;
  37.                 dSumF = dSumF + Fah;
  38.                 iRunde++;
  39.  
  40.                 if (Cel < dMinC) {
  41.                     dMinC = Cel;
  42.                 }
  43.                 if (Cel > dMaxC) {
  44.                     dMaxC = Cel;
  45.                 }
  46.                 dMidC = dSumC / iRunde;
  47.                
  48.                 if (Fah < dMinF) {
  49.                     dMinF = Fah;
  50.                 }
  51.                 if (Fah > dMaxF) {
  52.                     dMaxF = Fah;
  53.                 }
  54.                 dMidF = dSumF / iRunde;
  55.  
  56.                 printf("  %d. Wert:", iRunde);
  57.                 printf("\n     Fahrenheit: %3.1lf (min = %3.1lf, Mittel = %3.1lf, max = %3.1lf)", Fah, dMinF, dMidF, dMaxF);
  58.                 printf("\n     Celsius:    %3.1lf (min = %3.1lf, Mittel = %3.1lf, max = %3.1lf)\n\n", Cel, dMinC, dMidC, dMaxC);
  59.             }
  60.         }
  61.     } while (iRunde <= 254);
  62.  
  63.  
  64.     getchar();
  65.     return(0);
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement