lucy1.C
and
lucy2.C
produce exactly the same output.
Lucy in the Sky With Diamonds.
a
’s
with a
for
loop?
doublespace.C
.
Let the user decide if they want the output single spaced,
double spaced, triple spaced, etc.
charloop.C
:
int
to count through a series of consecutive numbers
(1
,
2
,
3
,
4
).
char
to count through a series of consecutive characters
('a'
,
'b'
,
'c'
).
line.C
.
Why are all the X
s on the same line?rectangle.C
.
Why are all the lines the same length?triangle1.C
and
triangle2.C
.
Why do the lines become longer and longer?parallelogram.C
.
Why are there more and more spaces in front of each line?graph1.C
:
no loop, hardwired to do 10 rows and 10 columns of boxes
graph2.C
:
one loop, inputs the number of rows, hardwired to output 10 columns.
graph3.C
:
nested loops, inputs the number of rows and columns.
How many rows of boxes (e.g., 10)? 2 How many columns of boxes (e.g., 10)? 4 How many rows of blanks in each box (e.g., 1)? 1 How many columns of blanks in each box (e.g., 3)? 4 +----+----+----+---- | | | | +----+----+----+---- | | | |
How many rows of boxes? 2 How many columns of boxes? 4 How many rows of blanks in each box (e.g., 1)? 3 How many columns of blanks in each box (e.g., 3)? 8 +--------+--------+--------+-------- | | | | | | | | | | | | +--------+--------+--------+-------- | | | | | | | | | | | |
solid.C
and
solid.png
:
Output a solid colored flag in
plain ppm format.
solid.C
has the same two-dimensional structure as
rectangle.C
.
jsmith@storm:~$ cd jsmith@storm:~$ wget https://markmeretzky.com/fordham/1600/src/nested/solid.C jsmith@storm:~$ ls -l (Should be a new file named solid.C) jsmith@storm:~$ c++ solid.C jsmith@storm:~$ ls -l (Should be a new file named a.out) jsmith@storm:~$ ./a.out | /usr/bin/pnmtopng > solid.png jsmith@storm:~$ ls -l (Should be a new file named solid.png) jsmith@storm:~$ file solid.png (Make sure that solid.png is a png file) solid.png: PNG image data, 30 x 20, 1-bit colormap, non-interlaced jsmith@storm:~$ cp solid.png public_html jsmith@storm:~$ cd public_html jsmith@storm:~$ ls -l (Should be a new file named solid.png)Then point your web browser at
https://storm.cis.fordham.edu/~jsmith/solid.png
jsmith
is your Fordham login name.
Put the three numbers of your color into255 0 0
red0 255 0
green0 0 255
blue255 215 0
gold192 192 192
silver184 115 51
copper128 128 0
olive0 255 255
aqua
solid.C
,
replacing my blue color 0 0 255
.
Run the C++ program,
together with the other program
/usr/bin/pnmtopng
,
following the instructions here.
Then can you see a little 20 × 30 image file of your chosen color
in your web browser?
factor.C
:
find the prime factors of an integer,
in order of increasing size.
sqrt(n)
,
so
#include <cmath>