| 1 | // File: fig0621.cpp |
| 2 | // Computer Systems, Fourth Edition |
| 3 | // Figure 6.21 |
| 4 | |
| 5 | #include <iostream> |
| 6 | using namespace std; |
| 7 | |
| 8 | int numPts; |
| 9 | int value; |
| 10 | int j; |
| 11 | |
| 12 | void printBar (int n) { |
| 13 | int k; |
| 14 | for (k = 1; k <= n; k++) { |
| 15 | cout << '*'; |
| 16 | } |
| 17 | cout << endl; |
| 18 | } |
| 19 | |
| 20 | int main () { |
| 21 | cin >> numPts; |
| 22 | for (j = 1; j <= numPts; j++) { |
| 23 | cin >> value; |
| 24 | printBar (value); |
| 25 | } |
| 26 | return 0; |
| 27 | } |