新手求帮助,第二个文件里count怎么不能用啊?!
parta.h
parta.h
#include<stdio.h> void report_count (); void accumutale (int k); int count = 0; int main(void) { int value; register int i; printf("Enter a positive integer(0 to quit): "); while(scanf("%d",&value)==1&&value>0) { count++; for(i = value;i >=0;i--) accumulate(i); printf("Enter a positive integer(o to quit): "); } report_count(); return 0; } void report_count() { printf("Loop executed %d times\n",count); } partb.h
#include<stdio.h> extern int count; static int total = 0; void accumutale(int k); void accumutale(int k) { static int subtotal = 0; if(k<=0) { printf("loop ctype: %d\n",count); printf("subtotal: %d: total: %d\n",subtotal,total); subtotal = 0; } else { subtotal++; total +=k; } }
解决方案:5分
什么叫“不能用”?
解决方案:15分
for (i = value; i >= 0; i--) accumulate(i);
accumulate拼写错了,你前面声明的是accumutale