w1369694898 于 2015.06.19 10:40 提问

#include
#include
#include
#define double B1 -2605573.350
#define double B2 3946395.001
#define double B3 4265605.723 //沈阳工业大学中央校区（基站）的三个坐标
#define ERR 1

void main()
{
int m;
FILE *fp;//建立一个文件操作指针
fp = freopen("D:\output1.txt", "w", stdout);//以追加的方式建立或打开output.txt，默认位置在你文件的目录下面
double G41 = -39648579.487;
double G42 = 14430902.764;
double G51 = 24253225.302;
double G52 = 34508849.018;
double G61 = 7179630.203;
double G62 = 41565625.567;
double d1;
double d2;
double d3; //基站到卫星的真实距离，根据已知可计算
double D1;
double D2;
double D3; //随机生成的基站到卫星的伪距，利用随机函数生成
for (m = 0; m <100; m++)
{
G41 = G41 + 10;
G42 = G42 + 10;
G51 = G51 + 10;
G52 = G52 + 10;
G61 = G61 + 10;
G62 = G62 + 10;
d1 = sqrt(pow(G41 - B1, 2) + pow(G42 - B2, 2) + pow(B3, 2));
d2 = sqrt(pow(G51 - B1, 2) + pow(G52 - B2, 2) + pow(B3, 2));
d3 = sqrt(pow(G61 - B1, 2) + pow(G62 - B2, 2) + pow(B3, 2)); //基站到卫星的真实距离计算
D1 = rand() % (20 * ERR) + d1 - 1;
D2 = rand() % (20 * ERR) + d2 - 1;
D3 = rand() % (20 * ERR) + d3 - 1; //随机生成的基站到卫星的伪距

``````    fprintf("%1f\n", D1);
//fprintf(fp, "%1f\n", D1); fprintf(fp, "\n");
fprintf(fp, "%1f\n", D2); fprintf(fp, "\n");
fprintf(fp, "%1f\n", D3);     //显示基站伪距
fprintf(fp, "\n");
}
fclose(fp);
``````

}

3个回答

beacon_2011   2015.06.19 12:23

G3110402105   2015.06.19 13:16

G3110402105   2015.06.19 13:19

fp = freopen("D:\output1.txt", "w", stdout);