Skip to content

Instantly share code, notes, and snippets.

@Shivani13121007
Created December 14, 2021 05:21
Show Gist options
  • Save Shivani13121007/d48173b470273eb3156933b26ffe5508 to your computer and use it in GitHub Desktop.
Save Shivani13121007/d48173b470273eb3156933b26ffe5508 to your computer and use it in GitHub Desktop.
pepcoding_pattern1
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
if(n<=0 || n>26)
{
cout<<"Enter a Valid number";
return 0;
}
for(int i =1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
if(i%2 == 0) cout<<(char)(j+64)<<" ";
else cout<<j<<" ";
}
cout<<endl;
}
return 0;
}
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
if(n<=0 || n>26)
{
System.out.println("Enter a Valid number");
return;
}
for(int i=1;i<=n;i++)
{
for(int j =1;j<=i;j++)
{
if(i%2 == 0) System.out.print((char)(j+64) + " ");
else System.out.print(j + " ");
}
System.out.println();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment