// input a line without spaces!
#inlcude <iostream>
char name[100]={};
cin>>name;
// input a line with space is stored.
string name1;
getline(cin, name1);
// start an .exe file from c++ code.
#include <windows.h>
{
system("timer.exe");
system("pause");
}
// calculate the run time of one part of code
#include <time.h>
{
clock_t start,finish;
double totaltime;
srand (1);
start=clock();
.....// your code here.
finish=clock();
totaltime=(finish-start)/static_cast<double>(CLOCKS_PER_SEC);
cout<<"totaltime for this code is: "<<totaltime<<" seconds."<<endl;
}
// sort array
#include <algorithm> // std::sort
const int n = 1000000;
int * x= new int[n]; // use dynamic memory
for (int i=0; i<n; i++)
{
x[i]= rand();
}
sort(x, x+n);