Skip to content

Commit 1fbb6e8

Browse files
author
miki's code
committed
Patterns question
1 parent 4e25e46 commit 1fbb6e8

File tree

11 files changed

+111
-0
lines changed

11 files changed

+111
-0
lines changed

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"files.associations": {
3+
"random": "cpp"
4+
}
5+
}

basics/halfP.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include<iostream>
2+
using namespace std ;
3+
int main(){
4+
int n ;
5+
cout << "Enter the n :: " ;
6+
cin >> n ;
7+
8+
9+
10+
for(int p = 1 ; p<=n ; p++ ){
11+
for(int q = 1 ; q <=p ; q++ ){
12+
13+
14+
15+
}
16+
17+
cout<< "\n" ;
18+
}
19+
return 0 ;
20+
}

basics/halfP.exe

43.7 KB
Binary file not shown.

basics/hollowR.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include<iostream>
2+
using namespace std ;
3+
int main(){
4+
int i , j ;
5+
cout << "Enter the number of rows and columns :: " ;
6+
cin >> i >> j ;
7+
8+
for(int p = 1 ; p<=i;p++ ){
9+
for(int q = 1 ; q <= j;q++ ){
10+
if(p==1 || p==i || q==1 || q==j){
11+
cout<<"*";
12+
}
13+
else{
14+
cout<<" ";
15+
}
16+
17+
}
18+
cout<< "\n" ;
19+
}
20+
return 0 ;
21+
}

basics/hollowR.exe

43.6 KB
Binary file not shown.

basics/invertedT.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include<iostream>
2+
using namespace std ;
3+
int main(){
4+
int i , j ;
5+
cout << "Enter the number of rows and columns :: " ;
6+
cin >> i >> j ;
7+
8+
for(int p = 1 ; p<=i;p++ ){
9+
for(int q = 1 ; q <= j; q++ ){
10+
cout<<"* ";
11+
12+
}
13+
j-- ;
14+
cout<< "\n" ;
15+
}
16+
return 0 ;
17+
}

basics/invertedT.exe

43.6 KB
Binary file not shown.

basics/nPrime.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
#include<iostream>
3+
using namespace std ;
4+
5+
int main(){
6+
7+
int n ;
8+
9+
cout << "Enter a number : "<< endl;
10+
cin >> n ;
11+
12+
for( int j = 2 ; j<=n ;j++){
13+
bool isPrime = true ;
14+
15+
for(int i = 2 ; i < j/2 ; i++){
16+
if(j%i == 0){
17+
isPrime = false ;
18+
break ;
19+
}
20+
21+
}
22+
23+
if(isPrime){
24+
cout<< j<<" ";
25+
}
26+
27+
}
28+
29+
30+
31+
32+
33+
}
Binary file not shown.

basics/rectangle.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include<iostream>
2+
using namespace std ;
3+
int main(){
4+
int i , j ;
5+
cout << "Enter the number of rows and columns :: " ;
6+
cin >> i >> j ;
7+
8+
for(int p = 0 ; p<i;p++ ){
9+
for(int q = 0 ; q <j;q++ ){
10+
cout<<"* ";
11+
}
12+
cout<< "\n" ;
13+
}
14+
return 0 ;
15+
}

0 commit comments

Comments
 (0)