Administracion de proyectos - Cifford
Enviado por Andrea Bandera • 17 de Abril de 2017 • Monografía • 348 Palabras (2 Páginas) • 131 Visitas
Ejemplo 1
//Listing 11.2
// Demonstrates what happens when you write past the end
// of an array
#include
using namespace std;
int main()
{
// sentinels
long sentinelOne[3];
long TargetArray[25]; // array to fill
long sentinelTwo[3];
int I, terminar;
for (i=0; i<3; i++)
sentinelOne[i] = sentinelTwo[i] = 0;
for (i=0; i<25; i++) TargetArray[i] = 0;
cout << "Test 1: \n";//test current values (should be0)
cout << "TargetArray[0]: " << TargetArray[0] << "\n";
cout << "TargetArray[24]: " << TargetArray[24] << "\n\n";
for (i = 0; i<3; i++)
{
cout << "sentinelOne[" << i << "]: ";
cout << sentinelOne[i] << "\n";
cout << "sentinelTwo[" << i << "]: ";
cout << sentinelTwo[i]<< "\n";
}
cout << "\nAssigning...";
for (i = 0; i<=25; i++)
TargetArray[i] = 20;
cout << "\nTest 2: \n";
cout << "TargetArray[0]: " << TargetArray[0] << "\n";
cout << "TargetArray[24]: " << TargetArray[24] << "\n";
cout << "TargetArray[25]: " << TargetArray[25] << "\n\n";
for (i = 0; i<3; i++)
{
cout << "sentinelOne[" << i << "]: ";
cout << sentinelOne[i]<< "\n";
cout << "sentinelTwo[" << i << "]: ";
cout << sentinelTwo[i]<< "\n";
}
cin >> terminar;
return 0;
}
Ejemplo 2
#include
using namespace std;
int main()
{
enum WeekDays { Sun, Mon, Tue,Wed, Thu, Fri, Sat, DaysInWeek };
int ArrayWeek[DaysInWeek] = { 10, 20, 30, 40, 50,60,70};
cout << "The value at Tuesday is: " << ArrayWeek[Tue];
return 0;
}
Ejemplo 3
#include
using namespace std;
int main()
{
int SomeArray[5][2] = { {0,0}, {1,2}, {2,4}, {3,6},
{4,8}};
for (int i = 0; i<5; i++)
for (int j=0; j<2; j++)
{
cout << "SomeArray[" << i << "][" << j << "]: ";
cout << SomeArray[i][j]<< "\n";
}
return 0;
}
...