请大家帮忙看看我的程序!小妹我刚学,谢谢了!
我的程序,但是验证的结果却是:
我用n来查看scanf是否把数据读进去了?可结果是n=2,我请请问各位这个问题怎么解决,我实在不知道我的错误出现在什么地方!请大家畅所欲言!谢谢,急!!!!!!!!!程序代码:
/*------------------------------- programmer: version: functional description: --------------------------------*/ #include <stdio.h> //function declaration void sum_n_avg(double *n1,double *n2,double *n3, double *sump, double *avgp); int main() { //function declaration double one, two, three, sum_of_3, avg_of_3; // Verify return value of scanf int n = 1; printf("please input three numbers>"); n = scanf("%.2lf,%.2lf,%.2lf\n",&one,&two,&three); sum_n_avg(&one, &two, &three, &sum_of_3, &avg_of_3); //print the result printf("sum_of_3 = %6.2f\n",sum_of_3); printf("avg_of_3 = %6.2f\n",avg_of_3); printf("n = %d",n); } void sum_n_avg(double *n1,double *n2,double *n3, double *sump, double *avgp) { *sump = *n1 + *n2 + *n3; *avgp = (*sump) / 3; }