c language of 4 * 5 ※ ladder (Hemopurification C Chapter 1, Question 5 5th edition) code to achieve a variety of implementations based on cycling

#include <stdio.h>
 int main () 
{ 
    / * int argc, char const * the argv [] * / 
    int I;
     int J;
     void printSpace (I);
     for (I = 0 ; I < . 4 ; ++ I ) {
         / * layer control line * / 
        printSpace (I); 
        for (J = 0 ; J < . 5 ; ++ J) { 
            the printf ( " * " ); 
        } 
        the printf ( " \ n- " ); // where Analyzing can be removed if the last wrap 
    }
    return  0 ; 
} 

void printSpace ( int I) {
     int J;
     for (J = 0 ; J <I; ++ J) { 
        the printf ( "   " ); // two spaces 
    } 
}

The effect is as follows:

As can be seen in line with requirements of the subject;

The first chapter did not learn cycle, Chapter 5 scholarship, according to the standard answer to the first chapter:

#include <stdio.h>
int main(){
    printf("*****\n");
    printf("  *****\n");
    printf("    *****\n");
    printf("      *****\n");
    return 0;
}

End ~

 

Guess you like

Origin www.cnblogs.com/m-yb/p/11427121.html