ITGUY82 - Editorial

Problem: Contest Page | CodeChef

DIFFICULTY:

EASY.

PROBLEM:

The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.

Program:

#include<bits/stdc++.h>
using namespace std;
 
int main()
 {
	//code
	
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
	      int x = 1, y = 1;
        for (int i = 1; i <= n; i++) {
            int temp = y;
            for (int j = 1; j <= i; j++) {
                if (i % 2 == 1)
                    cout<<x;
                else
                    cout<<temp--;
                x++;
                if (j != i)
                    cout<<'*';
            }
            y = y + i + 1;
        cout<<"\n";
        }
	}
}

Thank you for your work in hosting these contests for us as well as the editorials.

However, In my opinion, if you are just posting a solution in terms of code without any explanation, I don’t think it deserves to be called editorial, as anyone can see the code from successful submissions. I understand these questions are easy, but at least some level of explanation would be good if there is going to be 1 post per problem.

Please ignore if I am overreacting

2 Likes