⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex4_04.c

📁 [C语言入门经典(第4版)]整本书的源码!值得推荐!全部是最简单的源码!
💻 C
字号:
/*Exercise 4.1 Generate a multiplication table */
#include <stdio.h>

int main(void)
{
  int width = 0;                       /* Box width       */
  int height = 0;                      /* Box height      */

  printf("Enter the box width and height size separated by a space: ");
  scanf("%d", &width);
  scanf("%d", &height);

  for(int row = 0 ; row<height ; row++)
  {
    printf("\n");                      /* Start new row      */
    for(int col = 0 ; col<width ; col++)
    {
      if(row == 0||row==height-1)      /* 1st or last row?    */
      {
          printf("*");                 /* Yes - all asterisks */
          continue;
      }
      /* An * in 1st & last column, otherwise a space */
      printf("%c", ((col==0 || col==width-1) ? '*' :' '));
    }
  }
  printf("\n");
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -