Home > Back-end >  The ball ball bosses have a look at where there are problems
The ball ball bosses have a look at where there are problems

Time:04-06

Write a program to solve the sn=a + aa +... + a... A, in which a is 1-9 of a number, n is a positive integer, a and n are input from the keyboard, for example, type n is 4, a 2, sn=2 + 22 + 222 + 2222,

Thank you

CodePudding user response:

Nested loop x=0; What meaning?

CodePudding user response:

For reference only
 # include & lt; Stdio. H> 

Int Mult10 (int n)
{
Int sum=10;
Int m;
If (n==0) return 1;
For (m=1; MReturn the sum.
}

Int main () {
Int a, n, sn, x=0;
int i,j;
Printf (" a=? \n");
scanf("%d",& A);
Printf (n=?" \n");
scanf("%d",& N);
Sn=0;
for(i=0; i{
for(j=0; J<=I; J++)
X +=a * Mult10 (j);
Sn +=x;
X=0;
}
Printf (" sn=% d \ n ", sn);
return 0;
}

CodePudding user response:


CodePudding user response:

Input and output C=& gt; C + +
 
scanf("%d",& A);=& gt; Cin
Printf (n=?" \n");=& gt; Cout
  • Related