function takes only half of the inputs
Posted
by gcc
on Stack Overflow
See other posts from Stack Overflow
or by gcc
Published on 2010-06-05T09:36:46Z
Indexed on
2010/06/05
9:42 UTC
Read the original article
Hit count: 142
/*-> struct sam set_of_data[4] -<*/
int main (void)
{int k=0;
for(i=0;i<4;++i)
{ {char nm; double thelow,theupp; double numbers[200];
scanf("%c %lf %lf",&nm
,&thelow
,&theupp);
for(k=0;scanf("%lf",&numbers[k])!=0;++k)
;
set_of_data[i]=construct_struct(nm,thelow,theupp,numbers,k);
}
;
}
..
/* helper function to construct data structure*/
sam_t construct_struct(char name,double thelow,double theupp,double *numbers,int k)
{ stored_name_t stn;
stn.name=name;
stn.the_lower_limit=thelow;
stn.the_upper_limit=theupp;
for(i=0 ; i<k && numbers[k]!='\n' && numbers[k]!='\0' ; ++i)
stn.numbers[k]=numbers[k];
return stn;
}
these two funtion takes only half of the inputs(lines starting with D and B didnot be
taken,why?
inputs:
C 3.25 18. 0.01 .01 .02 .04 .08 .02 .02 .05 .065 .08 .1 .13 .2 .05 .04 .04 .03 .01 .005 .0
A 0 7.5 .054 .031 .016 .008 .116 .124 .147 .155 .039 .023 .016 .008 .124 .062 .031 .016 .008 .008 .008 .006
D -1.5 0.5 .012 .025 .05 .1 .1 .1 .025 .012 0 0 0 .012 .025 .1 .2 .1 .05 .039 .025 .025
B 1 3 .117 .058 .029 .015 .007 .007 .007 .015 .022 .029 .036 .044 .051 .058 .066 .073 .080 .088 .095 .103
© Stack Overflow or respective owner