gpt4 book ai didi

c - 怪异的迪基文件

转载 作者:行者123 更新时间:2023-11-30 17:02:38 25 4
gpt4 key购买 nike

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void get_file(void);
float Max_Horizontal(int, int);
float Max_Verticle(int, int);
float Time(int,int);

int main(void)
{

get_file();

return (0);
}

void get_file(void)
{
int i = 0;
int A[8][2];
char buf[1000];

FILE*Fpointin =fopen("trajin.txt","r");
FILE*Fpointout =fopen("trajout.txt","w");

if (Fpointin == NULL)
{
printf ("File does not exist.\n");
}
else
{
fgets(buf,1000, Fpointin);
}

while ((fscanf(Fpointin,"%d %d",&A[i][0],&A[i][1])==2))
{
{i++;}
fprintf(Fpointout, "%.2f\t %.2f\t %.2f\t %.2f\t %.2f \n", A[i][0],A[i][1], Max_Horizontal(A[i][0],A[i][1]), Max_Verticle(A[i][0],A[i][1]), Time(A[i][0],A[i][1]));
}
fclose(Fpointin);
fclose(Fpointout);
}

float Max_Horizontal(iInTrajectoryAngle,fInVelocity)
{
double fMaxRange = 0;

fMaxRange = ((pow(fInVelocity,2)*sin((((iInTrajectoryAngle*M_PI)/180)* 2)))/9.81);

return(fMaxRange);
}

float Max_Verticle(iInTrajectoryAngle,fInVelocity)
{
double fMaxHeight = 0;

fMaxHeight = (pow(fInVelocity,2) * pow(sin(((iInTrajectoryAngle*M_PI)/180)),2) / (2*9.81));

return (fMaxHeight);
}

float Time(iInTrajectoryAngle, fInVelocity)
{
double fFlightTime = 0;

fFlightTime = ((2 * fInVelocity * sin(((iInTrajectoryAngle*M_PI)/180))/9.81 ));

return (fFlightTime);
}

大家好,我已经为其中一个自动化在线类(class)完成了这个简短的程序,但输出文件很奇怪,我似乎不明白为什么。当然,该网站并没有多大帮助,因为它无法真正指出如何帮助修复我的错误。输入文件是一个简单的 .txt 文件,如下所示

初始角度(度) 初始速度(米每秒)10 10020 12030 13040 14050 15060 16070 17080180

最佳答案

想通了!必须改变

fprintf(Fpointout, "%f\t %f\t\t %.2f\t %.2f\t %.2f\n", A[i][0],A[i][1], Max_Horizontal(A[i][0],A[i][1]), Max_Verticle(A[i][0],A[i][1]), Time(A[i][0],A[i][1]));

fprintf(Fpointout, "%d\t %d\t\t %.2f\t %.2f\t %.2f\n", A[i][0],A[i][1], Max_Horizontal(A[i][0],A[i][1]), Max_Verticle(A[i][0],A[i][1]), Time(A[i][0],A[i][1]));

注意类型的变化。

关于c - 怪异的迪基文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36511804/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com