📄 cpp1.cpp
字号:
/*#include <math.h>*/
#include <stdio.h>
#include <conio.h>
int main()
{
double xb,xe; //计算区域横坐标起始位置
double yb,ye; //计算区域纵坐标起始位置
double d; //计算区域网格间距
printf("\nPlease input the parameters : ");
scanf("%lf %lf %lf %lf %lf",&xb,&xe,&yb,&ye,&d);
long m=(long)((xe-xb)/d)+1;
long n=(long)((ye-yb)/d)+1;
char sxgin[256];
char sxgout[256];
printf("\nPlease input the xdata file : ");
scanf("%s", sxgin);
printf("\nPlease input a file name to save the xresult : ");
scanf("%s", sxgout);
FILE* xgin = fopen(sxgin/*"x.cof"*/, "rt");
if(xgin == NULL)
{
printf("\nSorry!\nFailed to open the xfile \"%s\".\n", sxgin);
return -1;
}
FILE* xgout = fopen(sxgout/*"xresult.cof"*/, "wt");
if(xgout == NULL)
{
printf("\nSorry!\nFailed to open the xfile \"%s\".\n", sxgout);
return -1;
}
long xi,xj;
double xx1,xy1,xx2,xy2,xx,xy;
double xg1,xg2,xg;
long xnProcess = 0;
for(xi=0;xi<n-1;xi++)
{ xnProcess = (long)(xi*100/(n-1))+1;
printf("\b\b\b\b%2ld%%", xnProcess);
for(xj=0;xj<m-1;xj++)
{
fscanf(xgin, "%lf %lf %lf\n",&xy1,&xx1,&xg1);
fscanf(xgin, "%lf %lf %lf",&xy2,&xx2,&xg2);
xy=xy1;
xx=(xx1+xx2)/2;
xg=(xg2-xg1)/d;
fprintf(xgout,"%lf %lf %lf\n",xx,xy,xg);
}
}
fclose(xgout);
printf("\n\nx Calculating completed!\n");
char sygin[256];
char sygout[256];
printf("\nPlease input the ydata file : ");
scanf("%s", sygin);
printf("\nPlease input a file name to save the yresult : ");
scanf("%s", sygout);
FILE* ygin = fopen(sygin/*"y.cof"*/, "rt");
if(ygin == NULL)
{
printf("\nSorry!\nFailed to open the yfile \"%s\".\n", sygin);
return -1;
}
FILE* ygout = fopen(sygout/*"yresult.cof"*/, "wt");
if(ygout == NULL)
{
printf("\nSorry!\nFailed to open the yfile \"%s\".\n", sygout);
return -1;
}
long yi,yj;
double yx1,yy1,yx2,yy2,yx,yy;
double yg1,yg2,yg;
long ynProcess = 0;
for(yi=0;yi<m-1;yi++)
{ ynProcess = (long)(yi*100/(n-1))+1;
printf("\b\b\b\b%2ld%%", ynProcess);
for(yj=0;yj<n-1;yj++)
{
fscanf(ygin, "%lf %lf %lf\n",&yx1,&yy1,&yg1);
fscanf(ygin, "%lf %lf %lf",&yx2,&yy2,&yg2);
yx=yx1;
yy=(yy1+yy2)/2;
yg=(yg2-yg1)/d;
fprintf(ygout,"%lf %lf %lf\n",yx,yy,yg);
}
}
fclose(ygout);
printf("\n\ny Calculating completed!\n");
printf("\nPlease press any key to exit ...\n\n");
getch();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -