zoukankan      html  css  js  c++  java
  • 打印方格

    小明想在控制台上输出 m x n 个方格。
    比如 10x4的,输出的样子是:
    +---+---+---+---+---+---+---+---+---+---+
    | | | | | | | | | | |
    +---+---+---+---+---+---+---+---+---+---+
    | | | | | | | | | | |
    +---+---+---+---+---+---+---+---+---+---+
    | | | | | | | | | | |
    +---+---+---+---+---+---+---+---+---+---+
    | | | | | | | | | | |
    +---+---+---+---+---+---+---+---+---+---+

    (如果显示有问题,可以参见【图1.jpg】)

    以下是小明写的程序,请你分析其流程,填写划线部分缺少的代码。


    #include <stdio.h>

    //打印m列,n行的方格
    void f(int m, int n)
    {
    int row;
    int col;

    for(row=0; row<n; row++){
    for(col=0; col<m; col++) printf("+---");
    printf("+ ");
    for(col=0; col<m; col++) printf("| ");
    printf("| ");
    }

    printf("+");
    ; //填空
    printf(" ");
    }

    int main()
    {
    f(10,4);
    return 0;
    }

    注意:仅仅填写划线部分缺少的内容,不要添加任何已有内容或说明性文字。

  • 相关阅读:
    Spring MVC 体系结构和处理请求控制器
    Spring配置补充
    MyBatis与Spring的整合
    Ioc和AOP使用扩展
    JS 节流
    JS写返回上一级
    iframe父页面获取子页面的高度
    博客编写计划
    正则表达式
    实用 SQL 命令
  • 原文地址:https://www.cnblogs.com/8023spz/p/10567414.html
Copyright © 2011-2022 走看看