Skip to content

Commit

Permalink
uploading pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
ansiace authored Jan 11, 2025
1 parent aa75e0b commit 6245b85
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Pattern10.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include<iostream>
using namespace std;
int main(){
int i = 7 , j = 7 , k = 0 , n ;
int rows ;
cin>>rows;
n = ( rows + 1 ) / 2 ;
for ( i = 1 ; i <= rows ; i++ ){
if( rows % 2 == 0 ){
if ( i <= n ){
k++;
}
if( i > n + 1 ){
k--;
}
}
else
i <= n ? k++ : k-- ;
for ( j = 1 ; j <= rows ; j++ ){
if( j >= ( n + 1 ) - k && j <= ( n - 1 ) + k ){
cout<<"*";
}
else{
cout<<" ";
}
}
cout<<endl;
}
}
28 changes: 28 additions & 0 deletions Pattern9.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include<iostream>
using namespace std;
int main (){
int i = 4 , j = 7 ;
char k ;
for ( i = 1 ; i <= 4 ; i++ ){
k = 'A' ;
for( j = 1 ; j <= 7 ; j++ ){
if( j<= 5-i || j >= 3 + i ){
if ( j < 4){
cout<<k;
k++;
}
else{
cout<<k;
k--;
}
}
else{
cout<<" ";
if( j == 4 ){
k--;
}
}
}
cout<<endl;
}
}

0 comments on commit 6245b85

Please sign in to comment.