Basic C language algorithms 09-all are the sum of Series a and series 09

Source: Internet
Author: User

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.

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.