1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
double x = 974.23;
namespace one
{
double x = 56.1102;
}
namespace two
{
double x = 73.8924;
}
using std::cout; using std::cin;
void atEnd1(void) {cout << "Bye, bye!\n";}
void atEnd2(void) {cout << "Bye, bye, bye!\n";}
int main(int argc, char *argv[])
{
atexit(atEnd1); atexit(atEnd2);
double x = 11.001; short unsigned int i = 0;
cout << "This program ran with " << argc << " input arguments.\n ";
cout << "Do you know " << argv[2] << "?\n";
printf("Here is the second argument: %7.2f.\n",atof(argv[1]));
cout << "What will argv[1]+2 be? --> " << argv[1]+2 << "\n";
cout << one::x << " " << two::x << " " << ::x << " " << x << "\n";
std::vector<double> myVals(8,1.618);
for(i=0; i<myVals.size(); i++)
myVals[i] += i+1;
std::vector<double>::iterator vIt = myVals.begin();
double weirdMax = *(std::max_element(myVals.begin(),myVals.end()));
weirdMax += x;
cout << "weirdMax = " << weirdMax << ".\n";
cout << "The size and capacity of myVals are, respectively: ";
cout << myVals.size() << " and " << myVals.capacity() << ".\n";
return 1;
}
|
I want to know the output of this code. I tried to compile it but it just stopped after line 26.
Anyways other than that.
here's my questions
1) does line 23 output anything? does it output line 17 and line 18's couts?
2)in line 25 cout<<argc is it 2?
3) what is the output of argv[2]? My guess it means the second argument which is atEnd2 which is Bye, bye, bye!
4)i have no idea what line 27 do. I know it set the field width to be 10 and precision to be 2. But i don't nkow what does atof(argv[1])'s output
5) line 30 ::x and x output are both 11.001? and does line 30 output be affected by line 27?
6)what does line 32 do? to be exact what dose myVals(8,1.618) do? does it create a vector array of 8 and fill it with 1.618?
7)38~40's cout statements i can't plow through it.
8)line 28 the cout should be e bye!? becuase it's + so i think it's 2 sppace ahead.