#include <stdio.h>
#include <malloc.h>
#include <math.h>
int main()
{
char star;
int i, kor, eng, math, num, *sum;
double std_devi, average;
FILE *input_fp = fopen("1132422.inp", "r"), *output_fp = fopen("1132422.out", "w");
if(input_fp == NULL )
{
fprintf(stderr, "can't open %s\n", "1132422.inp" );
return 0;
}
if(output_fp == NULL )
{
fprintf(stderr, "can't open %s\n", "1132422.out" );
return 0;
}
if( ( sum = (int *)malloc( sizeof(int)*3 )) == NULL )
{
fprintf(stderr, "memory allocation error %s\n", "sum" );
}
fscanf(input_fp, "%d \n",&num);
for(i=0;i<num;i++)
{
fscanf(input_fp,"%d[^\t]%d[^\t]%d",&kor,&eng,&math);
*sum=kor+eng+math;
average=(double)kor+eng+math/num;
std_devi=(double)(kor*kor+eng*eng+math*math)/num-average*average;
fprintf(output_fp,"%.1lf \n",average);
fprintf(output_fp,"%.1lf \n",sqrt(std_devi));
}
fclose( input_fp );
fclose( output_fp );
free( sum );
return 0;
}
이젠 can't open 1132422.inp 등이 뜨지는 않는데 if문들 밑에 있는 fscanf 자식이 동작을 안하네요...
실행시키면 그냥 계속하려면 아무키나 누르십시용... 막 이럼 ㅠ 어디가 문제일까요
댓글 0