用C语言for循环编写,使用上一时刻的室温、此时刻的水温、此时刻的室外温度计算此时刻的室温,三个参数的系数为a、b、c,初始室温为t0,一共有10个时刻
时间: 2024-05-24 07:12:30 浏览: 4
#include <stdio.h>
int main() {
float a, b, c, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; // 定义系数和温度变量
printf("请输入系数a、b、c:");
scanf("%f %f %f", &a, &b, &c);
printf("请输入初始室温t0:");
scanf("%f", &t0);
// 根据公式计算各个时刻的室温
t1 = a * t0 + b * t0 + c * t0;
t2 = a * t1 + b * t1 + c * t1;
t3 = a * t2 + b * t2 + c * t2;
t4 = a * t3 + b * t3 + c * t3;
t5 = a * t4 + b * t4 + c * t4;
t6 = a * t5 + b * t5 + c * t5;
t7 = a * t6 + b * t6 + c * t6;
t8 = a * t7 + b * t7 + c * t7;
t9 = a * t8 + b * t8 + c * t8;
// 输出各个时刻的室温
printf("第1个时刻室温为:%f\n", t1);
printf("第2个时刻室温为:%f\n", t2);
printf("第3个时刻室温为:%f\n", t3);
printf("第4个时刻室温为:%f\n", t4);
printf("第5个时刻室温为:%f\n", t5);
printf("第6个时刻室温为:%f\n", t6);
printf("第7个时刻室温为:%f\n", t7);
printf("第8个时刻室温为:%f\n", t8);
printf("第9个时刻室温为:%f\n", t9);
printf("第10个时刻室温为:%f\n", a * t9 + b * t9 + c * t9);
return 0;
}
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)