fork download
  1. #include<stdio.h>
  2. void func(int n, int *p, int *f);
  3. int main(void)
  4. {
  5. int n, S=0, Factorial=1;
  6. printf("please input data: \n");
  7. scanf("%d",&n);
  8. func(n, &S, &Factorial);
  9. printf("n=%d 和%d 積%d\n",n, S, Factorial);
  10. return 0;
  11. }
  12.  
  13. void func(int n, int *p, int *f)
  14. {
  15. int i;
  16. for(i=1;i<=n;++i)
  17. {
  18. *p=*p+i;
  19. *f=*f*i;
  20. }
  21. }
  22.  
Success #stdin #stdout 0.01s 1680KB
stdin
5
stdout
please input data: 
n=5 和15 積120