게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
c언어 배열 뭐가문제죠??
게시물ID : computer_47796짧은주소 복사하기
작성자 : 복기치킨
추천 : 0
조회수 : 323회
댓글수 : 2개
등록시간 : 2012/05/22 01:20:57
#include <stdio.h>
#include <math.h>

int main()
{
double x[8],mean,st_dev,sum,sum_sqr;
int n;
int i;

printf("Enter the size of a vector > ");
scanf("%d",&n);

printf("Enter %d elements of the first vector > ",n);

for (i = 0; i < n; ++i)
scanf("%lf",&x[i]);

for (i = 0; i < 8; ++i)
{
sum += x[i];
sum_sqr += x[i] * x[i];
}

mean = sum / 8;
st_dev = sqrt(sum_sqr / 8 - mean * mean);
printf("The mean is %.2f.\n",mean);
printf("The standard deviation is %.2f.\n",st_dev);

printf("\nTable of differences between data values and mean\n");
printf("Index ITEM Difference\n");
for (i = 0; i < 8; ++i)
printf("%3d%4c%9.2f%5c%9.2f\n",i,' ',x[i], ' ',x[i]-mean);

return 0;
}

자꾸 실행시키면 실행은되는데 이상한거떠요 -21308921309218 이런식으로
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호