不断地输入温度 当用户输入假值时 如 ‘Q’ 则跳出 计算输入温度累加的平均温度 并输出

#include "stdafx.h"
#include "stdlib.h"
 
int main()  
{  
    int days=0;
    double ave=0,col;
 
    printf("Please input Temperature : ");
    while(scanf("%lf",&col)==1)
    {
        ave+=col;
        printf("Please input to calculate the average temperature Press 'Q' to quit : ");
        days++;
    }
 
    printf("%lf\n",ave/days);
    system("pause");
 
    return 0;  
}

你可能感兴趣的:(C)