Drill for Chapter 24 on page 922.
char
, a short
, an int
, a long
, a float
,
a double
, an int*
, and a double*
(use sizeof
, not <limits>
).sizeof
of Matrix<int> a(10)
, Matrix<int>
b(100)
, Matrix<double> c(10)
, Matrix<int,2> d(10,10)
, Matrix<int,3>
e(10,10,10)
.Matrix
es from 2.int
s from cin
and outputs the
sqrt()
of each int
, or “no square root” if sqrt(x)
is illegal for
some x
(i.e., check your sqrt()
return values).Matrix<double>
. Matrix has no push_back()
so be careful to handle an
attempt to enter a wrong number of double
s. Print out the Matrix
.[0,n)*[0,m)
and represent it as a 2D
Matrix
. Take n
and m
from cin
and print out the table nicely (assume that
m
is small enough that the results fit on a line).complex<double>
s from cin
(yes, cin
supports >>
for complex
)
and put them into a Matrix
. Calculate and output the sum of the ten complex numbers.int
s into a Matrix<int,2> m(2,3)
and print them out.How random is your default_random_engine
? Write a program that takes two integers n
and d
as inputs and calls randint(n)
d
times, recording the result. Output the number of draws for each of [0:n)
and “eyeball” how similar the counts are. Try with low values for n
and with low values for d
to see if drawing only a few random numbers causes obvious biases.
Write a random number generator to use in the final project. It must generate the arrivals of users at the elevator system. It has to return a triple consisting of the interarrival time since the previous user arrived, the floor of arrival and the destination floor. The interarrival time has to be exponentially distributed while the floors are draw from a uniform integer distribution between two numbers. Draw the histogram of the interarrival times generated.
Do exercises 4 and 5 of Chapter 24 on page 923. You find the code here.
Get the Gaussian elimination program to work; that is, complete it, get it to compile, and test it with a simple example.
Try the Gaussian elimination program with A=={ {0 1} {1 0} }
and b=={ 5
6 }
and watch it fail. Then, try elim_with_partial_pivot()
.