Basic C language algorithms-all are the sum of a's Series

Source: Internet
Author: User

Basic C language algorithms-all are the sum of a's Series
/*
========================================================== ======================================
Question: The number of columns is a, aa, aaa ,....... A + aa + aaa + ...... + Aaaaaaa .......
========================================================== ======================================
*/
# Include
Main ()
{
Int a, I, n, x, Sn, flag = 1;
While (flag)
{
Printf (the last item is a few digits: n = );
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! _________________________________);
X =;
Sn = x;
For (I = 1; I {
X = x * 10 +;
Sn + = x;
}
}
Printf (% d +... % d (% d) = % d, 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.
========================================================== ======================================
*/



 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.