Basic C language algorithms 09-all are the sum of Series a and series 09
/*
========================================================== ======================================
Question: The number of columns is a, aa, aaa ,....... A + aa + aaa + ...... + Aaaaaaa .......
========================================================== ======================================
*/
# Include <stdio. h>
Main ()
{
Int a, I, n, x, Sn, flag = 1;
While (flag)
{
Printf ("last digit: \ nn = ");
Scanf ("% d", & n );
Printf ("a = ");
Scanf ("% d", & );
If (a> 0) & (a <10) & (n> 0) & (n <10 ))
Flag = 0;
Else
Printf ("system prompt: both a and n must be a single-digit positive integer. Please try again! \ N _____________________________ \ n ");
X =;
Sn = x;
For (I = 1; I <n; I ++)
{
X = x * 10 +;
Sn + = x;
}
}
Printf ("% d +... % d (% d) = % d \ n ", a, n, Sn );
}
/*
========================================================== ======================================
Rating: determine the number of digits of the last item. input parameter a to repeatedly assign values to the intermediate parameter x, and sum the values.
========================================================== ======================================
*/
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.