Introduction to the data:
NOAA's National Centers for Environmental Information collects global climate data and aggregates this data to provide information on climate trends and variability. One product they offer is a monthly regional analysis. The following table gives "anomaly" data by continent for January 2017. "Anomaly" means the value is the temperature difference from the average temperature from years 1910–2000.
Continent Anomaly (C)
North America 3.18
South America 1.36
Your task is to develop an algorithm that would sort data such as these from least to greatest. Specifically, given an unsorted set of N decimal values, your algorithm should sort them to give an answer of the sorted data. For this set of N = 6, your algorithm should produce:
Execute your algorithm for a different set of data, such as a subset of the given data, data you make up, or another month's climate data, such as February 2017: https://www.ncdc.noaa.gov/sotc/global-regions/201702
Does your algorithm work for any N? Have you thought of corner cases it might need to handle, such as N = 0 or N = 1?
If the code actually runs it is only because of the way that the compiler lays down the stack and/or what the exact code did just before the first method was called.
In the method the pointer is considered to be non-initialized but because it is a pointer that was created on the stack it will have a value, whatever was in the memory that the stack is using at that point. Thus correctly stated 'garbage'.
I am trying to make a global 2D array using vectors, but I am having some trouble in doing so. Below code is a small part of my project where I need to make a global 2D array whose size has to be passed through a command line. I am passing row and column as command line arguments.
You declare your vector as a global, but the values of row and col will be zero when it is created. Make it a local variable and let your ESSolver object manage it. Or better still make it a member of the ESSolver class.
The array needs to be dynamically allocated. This is done using the new operator. I usually prepend an "m_" to member variable names so I know that is what they are. The array will be allocated in the class constructor and released in the destructor.
int * m_array;
cls( int length ); // constructor
~cls(); // destructorvoid print_array();
cls::cls( int length ) // constructor
m_length = length;
m_array = new int[length];
cls::~cls() // destructor
delete  m_array;
m_array = nullptr;
int main(int argc, char *argv)
int length = atoi( argv );
cls obj( length );