#include
#include
using namespace std;
struct tod
{
int hour;
int minute;
int second;
}; // tod
void printTod(tod& t)
{
cout.fill('0');
cout << setw(2) << t.hour << ':'
<< setw(2) << t.minute << ':'
<< setw(2) << t.second << endl;
cout.fill(' '); // set back to a space
}
int main()
{
tod noon = {12};
printTod(noon);
return 0;
} // main
Tuesday, April 26, 2011
todTest.cpp
Thursday, April 14, 2011
C++ bubbleSort
#include
#include
using namespace std;
void bubbleSort1(int* pa, int size)
{
int* pi = pa;
// 2 nested for-loops
for (int i = 0; i < size; i++)
{
int* pj = pi+1;
for (int j = i + 1; j < size; j++)
{
if ( *pi > *pj)
{
// swap code
int temp = *pi;
*pi = *pj;
*pj = temp;
} // if
pj++;
} // for
pi++;
} // for
} // bubbleSort1
void bubbleSort2(int* pa, int size)
{
for (int i = 0; i < size; i++)
{
for (int j = i + 1; j < size; j++)
{
if (pa[i] > pa[j])
{
// swap code
int temp = pa[i];
pa[i] = pa[j];
pa[j] = temp;
} // if
} // for
} // for
} // bubbleSort2
int main()
{
const int SIZE = 7;
int day[] = {8, 44, 33, 55, 908, 39, 88};
cout << "Unsorted: ";
int i;
for (i = 0; i < SIZE; i++)
cout << day[i] << ' ';
cout << endl;
bubbleSort2(day, SIZE);
cout << "Sorted: ";
for (i = 0; i < SIZE; i++)
cout << day[i] << ' ';
cout << endl;
return 0;
} // main
Wednesday, April 13, 2011
C++ pointer (step 1)
#include
using namespace std;
int main ()
{
int *x;
int c=200;
x=&c;
cout << " x is the address of c: " << x << endl;
cout << " *x points at c: " << *x << endl;
x++;
cout << " x is the address of c: " << x << endl;
cout << " *x points at c: " << *x << endl;
return 0;
}
C++ pointer (step 2)
#include
using namespace std;
int main ()
{
int age[5];
int *p;
int sum=0;
p=age;
for(int i=0;i<5;i++)
{
cout << "Enter the age of a student" << endl;
cin >> *p;
sum=sum+*p;
p++;
}
p=age;
cout << "The sum of the ages is : " << sum << endl;
cout << "The age of the last student is : " << *(p + 4) << endl;
return 0;
}
C++ pointer (step 3)
#include
using namespace std;
int arrayInputSum(int *pa, int size)
{
int *pp = pa;
int sum = 0;
for(int i=0;i
{
cout << "Enter the age of a student" << endl;
cin >> *pp;
sum=sum+*pp;
pp++;
}
return sum;
}
int main ()
{
int age[5];
int sum = arrayInputSum(age,5);
cout << "The sum of the ages is : " << sum << endl;
return 0;
}
Monday, March 21, 2011
lecture 7
Comsc-100 Lecture 7
Networking
Instructor: Prof. Tony Chern (tchern@dvc.edu)
Watch this space
This space at the end of the lecture notes is used in future lecture notes to include "how to's", with practical examples to help you with your lab assignments. These are not discussed in lectures or in any other written materials for this class, so make sure that you look for them yourself! Here's one now:
How to program
Right-click (or ctrl-click on Apple) here to download and save a brief, introductory PDF!
Friday, November 5, 2010
Puedes Contar conmigo
Mi mundo empezando a temblar
Presiento que se acerca el final
No quiero ganar, ahora eso qué más da
Estoy cansada ya de inventar
Excusas que no saben andar
Y sólo quedarán los buenos momentos de
Ayer que fueron de los dos
Y hoy sólo quiero creer
Que recordarás las tardes de invierno por Madrid
Las noches enteras sin dormir
La vida pasaba y yo sentía que me iba a morir de amor
Al verte esperando en mi portal sentado en el suelo sin pensar
Que puedes contar conmigo
Nunca hubo maldad, sólo ingenuidad
Pretendiendo hacernos creer que
El mundo estaba a nuestros pies
Cuando el sueño venga a por mí
En silencio voy a construir
Una vida a todo color donde vivamos juntos los dos
Y sólo quedarán los buenos momentos de
Ayer que fueron de los dos
Y hoy sólo quiero creer
Que recordarás las tardes de invierno por Madrid
Las noches enteras sin dormir
La vida pasaba y yo sentía que me iba a morir de amor
Al verte esperando en mi portal sentado en el suelo sin pensar
Que puedes contar conmigo para siempre
Y no puedo evitar echarte de menos
Mientras das la mano a mi tiempo y te vas
Yo siento que quiero verte y verte y pienso
Que recordarás las tardes de invierno por Madrid
Las noches enteras sin dormir
La vida pasaba y yo sentía que me iba a morir de amor
Al verte esperando en mi portal sentado en el suelo sin pensar
Que puedes contar conmigo
Que recordarás las tardes de invierno por Madrid
Las noches enteras sin dormir
La vida se pasa y yo me muero, me muero por ti