Wuhan University of Science and Technology Acm:1004:c Language Programming Tutorial (third Edition) after class exercise 6.3

Source: Internet
Author: User

Problem Description

Beg sn=2+22+222+...+22 ... A value of 222 (with N 2). For example: 2+22+222+2222+22222 (n=5), n is entered by the keyboard.

Input

N

Output

And

Sample Input
5
Sample Output
24690

My Code:
1#include <stdio.h>2 voidMain ()3 {4     intN,a=2, t,sum=0, I;5scanf"%d",&n);6t=A;7      for(i=1; i<=n;i++)8     {9sum=sum+T;Tent=t*Ten+A; One     } Aprintf"%d", sum); -}

Other code:

1#include <iostream>2 3 using namespacestd;4 5 intMain ()6 {7    Longsum=0;8    intt=2;9    intN;TenCin>>N; One     for(intI=0; i<n;++i) A    { -Sum + =T; -t =Ten*t+2; the    } -cout<<sum<<Endl; -     return 0; -}



Wuhan University of Science and Technology Acm:1004:c Language Programming Tutorial (third Edition) after class exercise 6.3

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.