tri.c

来自「linux下的C语言开发」· C语言 代码 · 共 32 行

C
32
字号
/*-*//******************************************************** * Question:						* *	This is designed to compute the area of 	* *      a triangle, given its width and height.		* *							* * For some strange reason, the compiler refuses to 	* * believe that we declared the variable "width".	* *							* * The declaration is right there on line 16,	 	* * just after the definition of height.  		* * Why isn't the compiler seeing it?			* ********************************************************//*+*/#include <stdio.h>char line[100];/* line of input data */int  height;   /* the height of the triangleint  width;    /* the width of the triangle */int  area;     /* area of the triangle (computed) */int main(){    printf("Enter width height? ");    fgets(line, sizeof(line), stdin);    sscanf(line, "%d %d", &width, &height);    area = (width * height) / 2;    printf("The area is %d\n", area);    return (0);}

⌨️ 快捷键说明

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