📄 fence.c
字号:
#include <stdio.h>
#include <math.h>
void main() {
double Length;
double Width;
double Area;
double Perimeter;
FILE *fp;
if ((fp = fopen("FenceIn.txt","r"))==NULL) {
printf("Cannot open file. \n");
exit(1);
}
/*GetInputs */
fscanf(fp,"Fence Input File\n");
fscanf(fp,"The length is: %lf\n", &Length);
fscanf(fp,"The width is: %lf\n", &Width);
fclose(fp);
/*calculate values */
Area = Length * Width;
Perimeter = 2 * Length + 2 * Width;
if ((fp = fopen("FenceOut.txt","w"))==NULL) {
printf("Cannot open file. \n");
exit(1);
}
fprintf(fp,"Fence Output File\n");
fprintf(fp,"The area is: %f\n",Area);
fprintf(fp,"The perimeter is: %f\n",Perimeter);
fclose(fp);
exit (0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -