Below program is giving different output in codeblocks and visual studio for same input
Input: 5 4 1 2 1
codeblocks
output: 0.00000000
#include<bits/stdc++.h>
using namespace std;
int main()
{
double l,d,v,g,r;
cin>>l>>d>>v>>g>>r;
if(g*v>d) printf("%.8lf\n",(double)l/v);
else
{
printf("%.8lf\n",ceil(d/v/(g+r)) * (g+r)+(l-d)/v);
}
return 0;
}
visual studio
output: 7.00000000
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
{
double l, d, v, g, r;
cin >> l >> d >> v >> g >> r;
if (g*v > d) printf("%.8lf\n", (double)l / v);
else
{
printf("%.8lf\n", ceil(d / v / (g + r)) * (g + r) + (l - d) / v);
}
return 0;
}
Is it due to headers or something else