c how to program 习题3.29

发布于2020-05-09 777 热度

运行结果:

C语言代码:

/* c how to program 习题3.29 */
#include <stdio.h>

// function main begins program execution
int main( void )
{
    //定义并初始化变量count为0
    unsigned int count = 10;
    //定义变量row
    unsigned int row;
    //当count少于10执行循环
    while( count-- > 0 ){
        //初始化row=1,
        row = 1;
        //用row控制循环,打印出10个字符
        while( row++ <= 10 ){
            //如果count为奇数,打印10个>字符,如果是偶娄打印10个<字符
            printf("%s", count%2 ? ">" : "<");
        }
        //换行
        puts("");
    }
} // end function main

记录工作,记录学习,分享知识,分享经验……