double f(double x){ return cos(2*pi*x*x*x); } void main(void){ long n; double x0 = 0; double x1 = 1; double ymin = 1.0e20; double xmin = x0; double x, y, dx; cin >> n; x = x0; dx = (x1 - x0)/n; for(long i=0; i<n; i++){ y = f(x); if(y < ymin){ ymin = y; xmin = x; } x += dx; } cout << xmin << endl; }
Back
Browse all jobs
Emulex seeking Senior Program Manager in Costa Mesa, CA
Accenture seeking Data Center Technology in Reston, VA
Eurotech seeking Sales Executive in Amaro, Italy
NYU Langone Medical Center seeking IS Manager in New York, NY