samedi 24 septembre 2022

Not able to solve a specific C++ pattern problem

I tried to make this problem but not getting solution . I want to print the pattern using c++ - This is pattern -

I tried this code but it is printing in reverse order .

  using namespace std;

  int main() {
    int n;
    cin>>n;
    
    int i = 1;
    
    while(i<=n){
        int j =1;
        while(j<=n){
            cout<<j;
            j=j+1;
        }
        cout<<endl;
        i=i+1;
    }

    return 0;
}

Output - 123 123 123

Can you please tell how to print that ?

Aucun commentaire:

Enregistrer un commentaire