A
Arash_89
Guest
Hello,
I want to trace Third variable. I want to debugging program and fix it. but I can't see Third.
Third has 15 elements.
#include <iostream>
using namespace std;
int main()
{
int first[] = { 4,15,19,32,44 };
int second[] = { 2,5,6,9,22,27,43,55,77,54 };
int FirstLength = sizeof(first) / sizeof(first[0]);
int SecondLength = sizeof(second) / sizeof(second[0]);
int* Third;
Third = new int[FirstLength + SecondLength];
for (int i = 0; i < FirstLength; i++)
{
Third = first;
}
int k = 0;
for (int i = FirstLength; i < FirstLength + SecondLength; i++)
{
Third = second[k];
int Key = Third;
int j = i - 1;
for (j = i; j >= 0 && Third[j] > Key; j--) {
Third[j + 1] = Third[j];
}
Third[j + 1] = Key;
k++;
}
for (int i = 0; i < FirstLength; i++)
{
cout << first << " ";
}
cout << endl;
for (int i = 0; i < SecondLength; i++)
{
cout << second << " ";
}
cout << endl;
for (int i = 0; i < FirstLength + SecondLength; i++)
{
cout << Third << " ";
}
}
Continue reading...
I want to trace Third variable. I want to debugging program and fix it. but I can't see Third.
Third has 15 elements.
#include <iostream>
using namespace std;
int main()
{
int first[] = { 4,15,19,32,44 };
int second[] = { 2,5,6,9,22,27,43,55,77,54 };
int FirstLength = sizeof(first) / sizeof(first[0]);
int SecondLength = sizeof(second) / sizeof(second[0]);
int* Third;
Third = new int[FirstLength + SecondLength];
for (int i = 0; i < FirstLength; i++)
{
Third = first;
}
int k = 0;
for (int i = FirstLength; i < FirstLength + SecondLength; i++)
{
Third = second[k];
int Key = Third;
int j = i - 1;
for (j = i; j >= 0 && Third[j] > Key; j--) {
Third[j + 1] = Third[j];
}
Third[j + 1] = Key;
k++;
}
for (int i = 0; i < FirstLength; i++)
{
cout << first << " ";
}
cout << endl;
for (int i = 0; i < SecondLength; i++)
{
cout << second << " ";
}
cout << endl;
for (int i = 0; i < FirstLength + SecondLength; i++)
{
cout << Third << " ";
}
}
Continue reading...