#include <iostream>

using namespace std;

void printpattern(int pattern_type, int pattern_size);//function call

int main()
{
        int pattern_type;
        int pattern_size;
        char ans;

        ans=='y';//this makes it loop until the uses enters a different character

        while (ans=='y' || ans == 'Y')
        {
                cout << "Please enter pattern type.\n";
                cin >> pattern_type;
                cout << "Please enter a pattern size.\n";
                cin >> pattern_size;

                printpattern(pattern_type, pattern_size);

 cout << "Please enter Y or y to continue. Enter any other character to exit the program.\n";
                cin >> ans;
        }

return 0;
}


void printpattern(int pattern_type, int pattern_size)
{

        if(pattern_size > 10 || pattern_size < 1)
        {
                cout << "Pattern size should be between (1-10)\n";
                return;
        }

        switch (pattern_type)
        {

        case 1:
                for (int i=0; i < pattern_size; i++)
                {
                        for (int j=0; j < pattern_size; j++)
                                if (i==j)
                                        cout << "\t" << "$";
                                else
                                        cout << ' ';
                        cout << endl;
                }
        case 2:
                for (int i=0; i < pattern_size; i++)
                {
                        for (int j=0; j < pattern_size; j++)
                                if (j <= i)
                                        cout << "$";
                        else
                                cout << ' ';

                        cout << endl;
                }
                break;
         case 3:
                for (int i=0; i < pattern_size; i++)
                {
                        for (int j=0; j < pattern_size; j++)
                                if (j >= i)
                                        cout << "$";
                                else
                                        cout << ' ';
                        cout << endl;
                }
                break;

        default:
                cout << "Pattern type should be between (1-3).\n";
        }
}