printing hourglasses pattern

hey!Hello I have a question about fuction that i have trouble with. I need to get 2 numbers. K and num1. For example num1=5 and k=2 the program will print this hourglass patterns: http://www.siz.co.il/my.php?i=2zfnzjtihh4z.jpg the function prints k hourglasses and each hourglass is built up from 1 to num1.
i have succeeded in doing 1 hourglass that is build up from 1 to num1.
i did 2 functions: 1 is upper part of hourglass and 2 is the bottom of it.
but i just cant figure how to do a third function that will print k hourglasses(and each with 1 space between them)..i dont want to change my 2 function i worked hard on them, i just want one that combines them and print k hourglasses. sorry for long post thanks for helpers

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
using namespace std;
void topTriangle(int num1, int k);
void bottomTriangle(int num1, int k);
 
 
void main()
{
        int num1, k;
        cout << "enter num1 and k" << endl;
        cin >> num1 >> k;
        topTriangle(num1, k);
        bottomTriangle(num1,k);
       
       
       
}
void topTriangle(int num1,int k)
{
        int   line, j;
        for (line = 1; line <= num1; line++)
        {
                for (j = 1; j < line; j++)
                {
                        cout << " ";
                }
                for (j = line; j <= num1; j++)
                {
                        cout << j;
                }
                for (j = num1 - 1; j >= line; j--)
                {
                        cout << j;
                }
                cout << "\n";
        }
}
void bottomTriangle(int num1,int k)
{
        int j, line;
        for (line = num1; line >= 1; line--)
        {
                for (j = 1; j < line; j++)
                {
                        cout << " ";
                }
                for (j = line; j <= num1; j++)
                {
                        cout << j;
                }
                for (j = num1 - 1; j >= line; j--)
                {
                        cout <<j;
                }
               
               
                cout << "\n";
        }
 
}  
anyone please?
Topic archived. No new replies allowed.