#include #include #include #include #define MAX 100 int n,i,j, N, which,count; float x[100], sum, dev; char input[10], output[10]; FILE *fptr; int main(){ initscr(); echo(); resize_term(35,80); if(!has_colors()){ endwin(); exit(0); } if(start_color() != OK){ endwin(); exit(0); } init_pair(1, COLOR_RED, COLOR_BLACK); init_pair(2, COLOR_YELLOW, COLOR_BLACK); init_pair(3, COLOR_BLUE, COLOR_BLACK); init_pair(0, COLOR_WHITE, COLOR_BLACK); init_pair(4, COLOR_BLACK, COLOR_YELLOW); init_pair(5, COLOR_CYAN, COLOR_BLACK); init_pair(6, COLOR_BLUE, COLOR_WHITE); move(1, 10); attrset(COLOR_PAIR(6)); printw("Statistical analysis"); attrset(COLOR_PAIR(0)); move(3, 1); printw("Interactive mode (i) or read from file (f)? "); attrset(COLOR_PAIR(2)); getstr(input); attrset(COLOR_PAIR(0)); which=-1; if(strcmp(input,"i")==0 || strcmp(input,"I")==0) which=0; if(strcmp(input,"f")==0 || strcmp(input,"F")==0) which=1; if(which==-1){ move(5,1); printw("Don't prompt OR read from file, bye-bye!"); refresh(); endwin(); exit(0); } if(which==0){ move(5,1); printw("How many numbers do you want to enter? "); attrset(COLOR_PAIR(2)); getstr(input); attrset(COLOR_PAIR(0)); N=atoi(input); if(N<0 || N>100){ move(7,1); printw("Sorry, thats out of range"); refresh(); endwin(); exit(0); } count=0; for(i=0;i<=N/5;i++){ for(j=0;j<5;j++){ if(count <= N-1){ move(9+2*i, 15*j); printw("x[%d]= ", count+1); attrset(COLOR_PAIR(1)); getstr(input); attrset(COLOR_PAIR(0)); x[count]=atof(input); count=count+1;} } } move(11+2*N/5, 1); sum=0.0; for(i=0;i100){ move(7,1); printw("Sorry, too many data points"); refresh(); endwin(); exit(0); } count=0; for(i=0;i<=N/5;i++){ for(j=0;j<5;j++){ if(count <= N-1){ move(9+2*i, 15*j); printw("x[%d]= ", count+1); attrset(COLOR_PAIR(1)); printw("%4.3f", x[count]); attrset(COLOR_PAIR(0)); count=count+1;} } } move(11+2*N/5, 1); sum=0.0; for(i=0;i to quit "); attrset(COLOR_PAIR(2)); getstr(input); endwin(); exit(0); }