test
This commit is contained in:
parent
37776af5db
commit
ab03d5f10c
4045 changed files with 286212 additions and 3 deletions
1
.config/Code/User/History/-57678f40/entries.json
Normal file
1
.config/Code/User/History/-57678f40/entries.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":1,"resource":"file:///home/rafayahmad/Downloads/232526/q8.cpp","entries":[{"id":"sFpu.cpp","timestamp":1717741536019}]}
|
||||
40
.config/Code/User/History/-57678f40/sFpu.cpp
Normal file
40
.config/Code/User/History/-57678f40/sFpu.cpp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
// The helper function is similar to mid exam (hollow Diamond)
|
||||
void printLine(int dimension, int stericCount,char character,int i=1) {
|
||||
// character can be * or o
|
||||
if (i>dimension){
|
||||
return;
|
||||
}
|
||||
|
||||
if (i <= stericCount || i > dimension - stericCount) {
|
||||
cout << character; // printing a character
|
||||
}
|
||||
else {
|
||||
cout << " ";
|
||||
}
|
||||
printLine(dimension,stericCount,character,i+1);
|
||||
}
|
||||
|
||||
void pattern1(const int dimension, int i=1) {
|
||||
|
||||
// Back tracking is mandatory, you can't use more than one if condition
|
||||
if(i<dimension/2+2){
|
||||
printLine(dimension, i, '*');
|
||||
printLine(dimension, i, 'O');
|
||||
cout<<endl;
|
||||
pattern1(dimension, i+1);
|
||||
printLine(dimension, i, 'O');
|
||||
printLine(dimension, i, '*');
|
||||
cout<<endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main(){
|
||||
cout << "Enter an odd integer: ";
|
||||
int number; cin >> number;
|
||||
cout << endl;
|
||||
pattern1(number);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue