c Language practice 18-- find s = a + aa + aaa + aaaa + aa ... the value of a, where a is a number

#include <stdio.h> 
#include <stdlib.h> 
#include <math.h>
 / * Title: seeking s = a + aa + aaa + aaaa + aa ... the value of a, where a is a number. E.g. 2 + 22 + 222 + 2222 + 22222 (in this case the sum total of the number 5), a control keyboard a few numbers together. * / 
Int main () { 
    System ( " Color 1F " );   // set the display frame for the blue white 
    System ( " MODE CON Lines cols = 80 = 30 " );   // fixed display frame size 
    / * *** ************************************** program body parting line (top) ***** ******************* * / 
    int S, P, A, I, T;
     the while ( . 1 ) { 
        S = 0 ;
        P = 0 ; 
        the printf ( " \ n-enter the range of 0-9 base number: " ); 
        Scanf ( " % D " , & A ); 
        the printf ( " Please enter the number of additions: " ); 
        Scanf ( " % D " , & T); 
        the printf ( " S = " );
         for (I = . 1 ; I <= T; I ++ ) { 
            P = P + A * POW ( 10 , I- . 1 ); 
            S = S + P;
             IF (I = =T)
                the printf ( " % D " , P);
             the else 
                the printf ( " % D + " , P); 
        } 
        the printf ( " =% D \ n-__________________________________________________________________________ \ n- " , S); 
    } 

    / * ********** ******************************* program body parting line (bottom) ************ ************** * / 
    return  0 ; 
}

 

Guess you like

Origin www.cnblogs.com/gougouwang/p/11401727.html
AA
AA