The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Given the following C++ code, improve the code by eliminating length calls out of the loop, put most used variables first when initializing variables, use prefix operators rather than postfix operators, loop unrolling, and any other improvements you would like to make to improve performance. Please note, the order of the output is not important, all data should be output.
Â
Â
#include
#include
#include
using namespace std;
Â
Â
int main(int argc, char* argv[])
{
double sum=0;
vector speed;
vector ship;
vector pilot;
Â
speed.push_back(12.0);
ship.push_back("Millenium Falcon");
pilot.push_back("Han solo");
speed.push_back(15.5);
ship.push_back("Viper");
pilot.push_back("Kara Thrace");
speed.push_back(22.0);
ship.push_back("Serenity");
pilot.push_back("Malcolm Reynolds");
Â
for(int i=0; i {
cout cout cout cout cout
Â
Â
Â
return 0;
}