Programmieren leicht erlernt |
dErgebnis = sqrt( dZahl ); |
dErgebnis = pow( dZahl1, dZahl2 ); |
dErgebnis = cos( dZahl ); |
dErgebnis = sin( dZahl ); |
dErgebnis = exp( dZahl ); |
dErgebnis = log( dZahl ); |
dErgebnis = log10( dZahl ); |
strcat( szString1, szString2); |
strcpy( szString1, szString2); |
nZahl = strlen( szString ); |
_strlwr( szString ); |
_strupr( szString ); |
_strrev( szString ); |
#include <stdlib.h> #include <time.h> #include <math.h> |
srand( (unsigned) time( NULL) ); |
double dRand; int nZahl; // Zufallszahl holen: // dRand = rand(); // Daraus eine Zahl zwischen 0 und 1 erstellen: // dRand /= RAND_MAX; // Daraus eine Würfelzahl erstellen: // dRand = dRand * 6 + 1; nZahl = (int) dRand |
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
main()
{
double dRand;
int nWuerfel1;
int nWuerfel2;
srand( (unsigned) time( NULL ) );
dRand = rand();
dRand /= RAND_MAX;
dRand = dRand * 6 + 1;
nWuerfel1 = (int) dRand;
dRand = rand();
dRand /= RAND_MAX;
dRand = dRand * 6 + 1;
nWuerfel2 = (int) dRand;
cout << "Mit dem ersten Wuerfel wurde eine ";
cout << nWuerfel1 << " gewuerfelt.\n";
cout << "Mit dem zweiten Wuerfel wurde eine ";
cout << nWuerfel2 << " gewuerfelt.\n";
cout << "Sie koennen deshalb ";
cout << nWuerfel1 + nWuerfel2 << " Felder weiterziehen.\n";
if ( nWuerfel1 == nWuerfel2 )
{
cout << "Da sie einen Pasch gewuerfelt haben,";
cout << " duerfen sie gleich nocheinmal wuerfeln.\n";
}
return 0;
}
|
srand( (unsigned) time( NULL ) ); |
srand( (unsigned) time( NULL ) ); rand(); |