내가 처음으로 질문을하는 이유는 무엇이든 걸려 넘어지면 용서할 수 있기 때문입니다. 저는 자동차 용 서스펜션 시스템을위한 프로젝트를 진행하고 있습니다. 나는 자동차와 타이어의 변위와 자동차와 타이어의 속도에 4 가지 기능을 필요로했다. 코드를 잘 구조화했다고 생각하지만 단순히 최종 제품을 출력하지 않습니다. 주요 목적은 각 기능의 최대 값을 찾는 것입니다. 시도하고 수정하기 위해 많은 노력을했지만 해결 방법을 찾지 못했습니다. 요점은 다음과 같습니다. 필자는 데이터 파일이 끝날 때까지 정보를 제공하는 네 가지 기능을 가진 프로그램을 구성했습니다. 내가 그것을 실행하려고하면 헤더가 출력됩니다. 나는 이것이 어땠는지 길을 잃었습니다.파일의 끝 부분을 어떻게 출력합니까?
데이터 파일은 자동차 A로부터 자동차 D에 이르기까지 네 그룹은 봄 타이어의 상수, 대시 냄비의 젖은 일정, 바퀴의 질량 자동차의 대량, 시작/종료 시간, 증분 값 ,과 같이 정리하고있다
함수 자체는 일종의 ... 삼키기 어렵습니다. 그래서 나는 문제가 있다고 생각하는 부분의 코드를 공유하고 싶다.
모든 도움말/힌트/의견을 보내 주시면 감사하겠습니다.
csdatafiles>> total_readings;
csdatafiles >> car_name >> spring_constant_tire >> spring_constant_spring
>> damp_constant >> mass_of_tire >> mass_of_car
>> start_time_value >> end_time_value >> increment_time_value;
//Initialize max min
max_displacement_car=displacement_of_car;
max_displacement_tire=displacement_of_tire;
max_velocity_car=velocity_of_car;
max_velocity_tire=velocity_of_tire;
//Output Header
cout << "\nCar Name Max Tire Displace Max Tire Vel Max Car Displace Max Car Vel \n" << endl;
{
//recall functions
velocity_of_tire= old_new_tire_velocity (variables needed);
velocity_of_car=old_new_car_velocity (variables needed);
displacement_of_car= old_new_car_displacement (variables needed);
//check for max
if (displacement_of_car>max_displacement_car)
max_displacement_car=displacement_of_car;
if (displacement_of_tire>max_displacement_tire)
max_displacement_tire=displacement_of_car;
if (velocity_of_car>max_velocity_car)
max_velocity_car=velocity_of_car;
if (velocity_of_tire>max_velocity_tire)
max_velocity_tire=velocity_of_tire;
total_readings++;
//read rest of data
csdatafiles >> spring_constant_tire >> spring_constant_spring
>> damp_constant >> mass_of_tire >> mass_of_car
>> start_time_value >> end_time_value >> increment_time_value;
} while (!csdatafiles.eof());
//Output
cout << car_name << max_displacement_tire << max_velocity_tire << max_displacement_car << max_velocity_car;
작고 간단하게 시작하고, 복잡성을 조금씩 추가하고, 모든 단계에서 테스트하고, 작동하지 않는 코드에 절대 추가하지 마십시오. * 데이터 파일을 읽은 후이를 밖으로 내뱉는 함수로 시작해야합니다 한 번에 필드를 만들고 거기에서 빌드하십시오. – Beta
아마 주요한 문제는 아니지만 max-statements 중 하나는 타이어의 변위를 자동차의 변위로 설정합니다. max_displacement_tire = displacement_of_car; –