求1+x+x^2⼀2!+x^3⼀3!……+x^n⼀n! c语言编程题

2024-11-17 16:04:10
推荐回答(1个)
回答1:

#includeintpow(inta,intn);voidmain(){inta,n;registerints=0,i;printf("输入底数a\n");scanf("%d",&a);printf("输入指数n\n");scanf("%d",&n);for(i=n;i>0;i--)s=s+pow(a,i);printf("%d^1+%d^2+.+%d^%d=%d\n",a,a,a,n,s);}intpow(inta,intn){registerintc=1;for(;n>0;n--)c=c*a;returnc;}