标签:输入 for 计算 c语言 turn log 入门 stdio.h use
#include <stdio.h> #include <stdlib.h> int main(void) { int i, j, n; double sum, **day = NULL; printf("请输入你要计算的天数:"); scanf_s(" %d", &n , sizeof(int)); printf("\n\n"); day = calloc(n, sizeof(double*)); for (i = 0; i < n; ++i) { *(day + i) = calloc(6, sizeof(double)); sum = 0.0; for (j = 0; j < 6; ++j) { printf("请输入第%d天第%d个温度:", i + 1, j + 1); scanf_s(" %lf", day[i] + j); sum += day[i][j]; } printf("第%d天的六个温度为:", i + 1); for (j = 0; j < 6; ++j) printf("%lf ", day[i][j]); printf("\n第%d天的平均温度为:%.1lf\n\n\n", i + 1, sum / 6.0); } for (i = 0; i < n; ++i) free(day[i]); free(day); system("pause"); return 0; }
标签:输入 for 计算 c语言 turn log 入门 stdio.h use
原文地址:http://www.cnblogs.com/isham/p/7511681.html