vendredi 27 janvier 2023

How to print character in zig zag pattern

I want to print character in zig zag pattern well I already tried but I'm only able to print star in zig zag pattern

star pattern

**Code of star zig zag pattern **

#include <iostream>
using namespace std;

int main() 
{
    int n;
    cin >> n;
    for(int i = 1; i <= 3; i++)
    {
        for(int j = 1; j <= n; j++){
            if(((i + j) % 4 == 0) || (i == 2 && j % 4 == 0)){
                cout << "* ";
            }
            else{
                cout << "  ";
            }
        }
        cout << endl;
    }
    return 0;
}

I want to print character in zig zag pattern

String in zig zag pattern

Aucun commentaire:

Enregistrer un commentaire