小白 求老师改错
本人新学C语言比较笨,最近一个编程老是改不对求老师指出错误。-----------------------------------
程序代码:
#include"stdio.h" void values(int *a,int *b, int *c) { int x,y,z; printf("Enter a whole number: "); scanf("%d",&x); *a=x; printf("Enter a second whole number: "); scanf("%d",&y); *b=y; printf("Enter a third whole number: "); scanf("%d",&z); *c=z; } int smallest(int *a, int *b, int *c) { int small=*a; if (*a>*b){ small=*b; } if (*b>*c){ small=*c; } return small; } int largest(int *a, int *b, int *c) { int large=*a; if (*a<*b){ large=*b; } if (*b<*c){ large=*c; } return large; } void a2question2() { int *a,*b,*c,sum,product; float average; values(a,b,c); sum = *a+*b+*c; average = (*a+*b+*c)/3; product = *a**b**c; printf("Sum = %d\nAverage = %.2f\nProduct = %d\nSmallest = %d\nLargest = %d\n",sum,average,product,smallest(a,b,c),largest(a,b,c)); } int main() { a2question2(); return 0; }最后出现 segment fault. 我不知道指针哪里不对了。