#include
int main()
{
long fun(int a,int n);
int a,n;
long Sn;
scanf("%d%d",&a,&n);
Sn=fun(a,n);
printf("Sn=%ld\n",Sn);
return 0;
}
long fun(int a,int n)
{
int i,num=a;
long sum=a;
for(i=1;i
num=num*10+a;
sum+=num;
}
return sum;
}
#include
int sum(int a,int n)
{
int i,j,result = 0,ji;
for(i=1;i<=n;i++)
{
ji = 1;
for(j = 1;j<=i;j++)
{
ji*=a;
}
result += ji;
}
return result;
}
int main(void)
{
int a,n,resu;
printf("请输入a和n的值");
scanf("%d %d",&a,&n);
resu = sum(a,n);
printf("结果是%d \n",resu);
return 0;
}
如果看得懂就采了吧,看不懂就不用采,谢谢!
int Fn(int n,int a){
int sum=a;
for(int i=2;i<=n;i++){
a+=a*10;
sum+=a;
}
return sum;
}
int main()
{
int n=0,a=0;
printf("please input n and a:\n");
scanf_s("%d,%d",&n,&a);
int result=Fn(n,a);
printf("sum is :%d\n",result);
getchar();
}
#include
void main()
{
int n,a,i,j,pre=0,ji,sum=0;
printf("please input n a:\n");
scanf("%d%d",&n,&a);
for(i=1;i<=n;i++)
{
ji=1;
for(j=1;j ji*=10;
pre=pre+a*ji;
sum+=pre;
}
printf("the result is %d\n",sum);
}