#include
int fn(int a, int n)
{
int sum = a, tem = a;
printf("%d", tem);
for (int i = 2; i <= n; i++)
{
tem = tem * 10 + a;
printf(" + %d", tem);
sum += tem;
}
return sum;
}
int main()
{
int a, n;
printf("input a and n:");
scanf("%d %d", &a, &n);
printf(" = %d\n", fn(2, 5));
return 0;
}
楼主你好!
根据你的要求,我实现代码如下!
#include
int fun(int a,int n){
int sum1=0,sum2=0;
for(int i=0;i sum1=sum1*10+a; sum2+=sum1; } return sum2; int main(){ int a,n; printf("Enter the a and n: "); scanf("%d%d",&a,&n); printf("result: %d",fun(a,n)); 希望我的回答对你有帮助!望采纳!
#include
int fn( int, int );
int main()
{
int a, n;
scanf( "%d %d", &a, &n );
printf( "%d\n", fn( a, n ) );
return 0;
}
int fn( int a, int n )
{
int i, result = 0;
for ( i = 0; i < n; i++ )
{
result += a;
a = a * 10 + a % 10;
}
return result;
}
#include
#include
int fun(a,n)
{
int i,j,k,s=0;
for(i=1;i<=n;i++)
{
k=0;
for(j=1;j<=i;j++)
{
k=k+a*(int)pow(10,j);
}
s=s+k;
}
return s;
}
int main()
{
int a,n;
scanf("%d %d",&a,&n);
printf("%d\n",fun(a,n));
return 0;
}
fn(a,n)=f(a,n-1)*10+a