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

📄 ex2_01.c

📁 [C语言入门经典(第4版)]整本书的源码!值得推荐!全部是最简单的源码!
💻 C
字号:
/* Exercise 2.1 Convert inches to yards, feet, and inches */
#include <stdio.h>

int main(void)
{
  int inches = 0;
  int yards = 0;
  int feet = 0;
  const int inches_per_foot = 12;
  const int feet_per_yard = 3;

  printf("Enter a distance in inches: ");
  scanf("%d", &inches);

  feet = inches/inches_per_foot;  /* get whole feet          */
  yards = feet/feet_per_yard;     /* Get whole yards in feet */
  feet %= feet_per_yard;          /* Get residual feet       */
  inches %= inches_per_foot;      /* Get residual inches     */

  printf("\nThat is equivalent to %d yards %d feet and %d inches.\n",
                                                    yards, feet, inches);
  return 0;
}

⌨️ 快捷键说明

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