Patternu IV
Write a program to print the given below pattern.
Sample Input:
5
Sample Output:
11112
32222
33334
54444
55556
Case 1
Case 2
Case 3
Input (stdin)
5
Output (stdout)
11112
32222
33334
54444
55556
Answers
Answered by
0
4567890589 is the Answer
Answered by
0
Answer:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int m;
cin>>m;
for(int i = 1 ; i<=m;i++)
{
if(i%2 == 1)
{
for(int j=0;j<m-1;j++)
{
cout<<i;
}
cout<<i+1;
cout<<"\n";
}
else
{
cout<<i+1;
for(int j=0;j<m-1;j++)
{
cout<<i;
}
cout<<"\n";
}
}
}
Explanation:
All tests passed
Similar questions
Math,
5 months ago
Physics,
5 months ago
Social Sciences,
10 months ago
English,
10 months ago
Science,
1 year ago