shoes1.c & shoes2.c
This commit is contained in:
parent
9a08a37e8a
commit
6e9110b590
17
c05_expression/shoes1.c
Normal file
17
c05_expression/shoes1.c
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/* shoes1.c - 把鞋码转换成英寸 */
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define ADJUST 7.31
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
const double SCALE = 0.333;
|
||||||
|
double shoe, foot;
|
||||||
|
|
||||||
|
shoe = 9.0;
|
||||||
|
foot = SCALE * shoe + ADJUST;
|
||||||
|
printf("Shoe size (men's)\tfoot length\n");
|
||||||
|
printf("%10.1f\t%15.2f inches\n", shoe, foot);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
22
c05_expression/shoes2.c
Normal file
22
c05_expression/shoes2.c
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/* shoes2.c - 计算多个不同鞋码对应的脚长 */
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define ADJUST 7.31
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
const double SCALE = 0.333;
|
||||||
|
double shoe, foot;
|
||||||
|
|
||||||
|
printf("Shoe size (men's)\tfoot length\n");
|
||||||
|
shoe = 3.0;
|
||||||
|
while (shoe < 18.5)
|
||||||
|
{
|
||||||
|
foot = SCALE * shoe + ADJUST;
|
||||||
|
printf("%10.1f\t%15.2f inches\n", shoe, foot);
|
||||||
|
shoe = shoe + 1.0;
|
||||||
|
}
|
||||||
|
printf("If the shoe fits, wearit.\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user