#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#define BUFFER_LEN 256
#define NUM_P 42
int main(void)
{
char input[BUFFER_LEN];
char *pinput = input;
char buffer[BUFFER_LEN];
double pS[NUM_P];
double *ppS = pS;
int index = 0;
int count = 0;
int j =0;
double zhuanhuan = 0;
printf("请输入任意天数的浮点温度值,其中6个值为一天,温度值之间用加号隔开\n:");
while((*pinput++ = getchar()) != '\n');
*(pinput-1) = '\0';
pinput = input;
while(*pinput != '\0')
{
if(count != 0 && count%5 == 0)
{
ppS = (double *)malloc(sizeof(double)*index);
if(ppS==NULL)
{
printf("x");
getch();
return 1;
}
strcpy(pS[j++],zhuanhuan);
zhuanhuan = 0;
}
index = 0;
while(isdigit(*(pinput)) || *pinput == '.')
buffer[index++] = *pinput++;
if(*pinput== '+'|| *pinput =='\0')
{
++count;
*pinput++;
buffer[index]='\0';
zhuanhuan += atof(buffer);
}
}
printf("%d\n",j);
if(count <5)
printf("还不到一天6个浮点温度值\n");
else
for(int k = 0; k<j; k++)
{
printf("低%d天的平均温度值是%f\n",k+1,pS[k]/6);
}
getch();
return 0;
}