Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Wiederholtes Einlesen und Berechnen von Temperaturwerten *
- * Autor: Philipp Heckenmüller *
- * Datum: 27.11.2014 */
- #define _CRT_SECURE_NO_WARNINGS
- #include<stdio.h>
- int main(void) {
- double dMaxC = 0, dMinC = 100, dMidC, dSumC = 0, dMaxF = 0, dMinF = 100, dMidF, dSumF = 0, Cel, Fah;
- int iRunde = 0, iGelesen;
- do {
- printf("Temperatur in \xF8""Celsius (0 ... 100, Strg + z zum Beenden): ");
- iGelesen = scanf("%lf", &Cel);
- fflush(stdin);
- if (iGelesen == 0) {
- printf(" Bitte geben Sie eine Zahl ein!\n\n");
- }
- if (iGelesen == -1) {
- printf(" Eingabe beendet\n\nBericht:\n Es wurden %d Werte eingegeben:", iRunde);
- printf("\n Fahrenheit: min = %3.1lf, Mittel = %3.1lf, max = %3.1lf)", dMinF, dMidF, dMaxF);
- printf("\n Celsius: min = %3.1lf, Mittel = %3.1lf, max = %3.1lf)", dMinC, dMidC, dMaxC);
- 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!)...
- }
- if (iGelesen == 1) {
- if (Cel > 100) {
- printf("Die Zahl ist zu gro\xE1 (%3.1lf > 100)!\n\n", Cel);
- }
- if (Cel < 0) {
- printf("Die Zahl ist zu klein (%3.1lf < 0)!\n\n", Cel);
- }
- if (Cel >= 0 && Cel <= 100) {
- Fah = (Cel * 1.8) + 32;
- dSumC = dSumC + Cel;
- dSumF = dSumF + Fah;
- iRunde++;
- if (Cel < dMinC) {
- dMinC = Cel;
- }
- if (Cel > dMaxC) {
- dMaxC = Cel;
- }
- dMidC = dSumC / iRunde;
- if (Fah < dMinF) {
- dMinF = Fah;
- }
- if (Fah > dMaxF) {
- dMaxF = Fah;
- }
- dMidF = dSumF / iRunde;
- printf(" %d. Wert:", iRunde);
- printf("\n Fahrenheit: %3.1lf (min = %3.1lf, Mittel = %3.1lf, max = %3.1lf)", Fah, dMinF, dMidF, dMaxF);
- printf("\n Celsius: %3.1lf (min = %3.1lf, Mittel = %3.1lf, max = %3.1lf)\n\n", Cel, dMinC, dMidC, dMaxC);
- }
- }
- } while (iRunde <= 254);
- getchar();
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement