我想知道这个代码哪里做了,谢谢。
/* Pragram 2.18 Calculating the heighe of a there */#include <stdio.h>
int main(void)
{
long shorty = 0L; // 矮子在英寸的高度
long lofty = 0L; // 左边在英寸的高度
long feet = 0L;
long inches = 0L;
long shorty_to_lofty = 0L; // 矮个子到高个子的距离
long lofty_to_tree = 0L; // 高个子到树的距离
long tree_height = 0L; // hight of the in inchies
const long inches_per_foot = 12L;
// Get Lofty's height
printf("Enter Lofty's hight to the top of his/her head, in whole feet: ");
scanf("%ld", &feet);
printf(" ... and then inches: ");
scanf("%ld", &inches);
lofty = feet*inches_per_foot + inches;
// Get Shorty's height up to his/her eyes
ptintf("Enter Shorty's heinght up to his/her eyes, in whole feet: ");
scanf("%ld", &feet);
printf(" ... and there inches: ");
scanf("%ld", &inches);
shorty = feet*inches_per_foot + inches;
// Gat the distance from Shorty to Lofty
printf("Enter the distance between Shorty and Lofty, in whole feet: ");
scanf("%ld", &feet);
printf(" ... and then inches: ");
scanf("%ld", &inches);
shorty_to_lofty = feet*inches_per_foot + inches;
// Get thes distance from Lofty to the tree
printf("Finally enter the distance from Lofty to the tree to the nearest foot: ");
scanf("%ld", &feet);
lofty_to_tree = feet*inches_per_foot;
// Calculate the height of the tree in incher
tree_height = shorty + (shorty_to_lofty + lofty_to_tree)*(lofty-shorty)/shorty_to_lofty;
// Dispiay the result in feet and inches
printf("The height of the tree is %ld feet and %ld inches.\n", tree_height/inches_per_foot, tree_height%inches_per_foot);
return 0;