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

📄 macro.c

📁 c版本的
💻 C
字号:
                                        /* Chapter 6 - Program 2 */
#define WRONG(A) A*A*A          /* Wrong macro for cube     */
#define CUBE(A) (A)*(A)*(A)     /* Right macro for cube     */
#define SQUR(A) (A)*(A)         /* Right macro for square   */
#define ADD_WRONG(A) (A)+(A)    /* Wrong macro for addition */
#define ADD_RIGHT(A) ((A)+(A))  /* Right macro for addition */
#define START 1
#define STOP  7

main()
{
int i,offset;

   offset = 5;
   for (i = START;i <= STOP;i++) {
      printf("The square of %3d is %4d, and its cube is %6d\n",
              i+offset,SQUR(i+offset),CUBE(i+offset));
      printf("The wrong of  %3d is %6d\n",i+offset,WRONG(i+offset));
   }

   printf("\nNow try the addition macro's\n");
   for (i = START;i <= STOP;i++) {
      printf("Wrong addition macro = %6d, and right = %6d\n"
                               ,5*ADD_WRONG(i),5*ADD_RIGHT(i));
   }
}

⌨️ 快捷键说明

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