An open API service indexing awesome lists of open source software.

https://github.com/arshdeepsahni/cpp

CPP
https://github.com/arshdeepsahni/cpp

code cpp

Last synced: 10 months ago
JSON representation

CPP

Awesome Lists containing this project

README

          

> # CPP - Some C++ Codes.
|

[Patterns1](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns1.cpp)

|

[CODE](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns1.cpp)

|
|---|---|
| `CUSTOM EXAMPLES` `INPUT` `OUTPUT` 4 **** **** **** **** | ```#include ```
```using namespace std;```
``` int main()```
```{```
``` int i=1,n,j=1;```
``` cin>>n;```
``` while(i<=n)```
```{ ```
``` j=1;```
``` while(j<=n)```
```{```
``` cout<<'*';```
``` j++; ```
``` }```
```i++;```
```cout<```}```
```return 0;```
```}```|

|

[Patterns2](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns2.cpp)

|

[CODE](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns2.cpp)

|
|---|---|
| `CUSTOM EXAMPLES` `INPUT` `OUTPUT` 4 1234 1234 1234 1234 |```#include ```
```using namespace std;```
```int main()```
```{```
``` int n;```
``` cin>>n;```
```int i=1;```
```while(i<=n)```
``` {```
``` int j=1;```
```while(j<=n)```
```{```
```cout<```j++;```
```}```
```i++;```
```cout<```}```
```return 0;```
```}```|

|

[Patterns3](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns3.cpp)

|

[CODE](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns3.cpp)

|
|---|---|
| `CUSTOM EXAMPLES` `INPUT` `OUTPUT` 4 1111 2222 3333 4444 |```#include ```
```using namespace std;```
```int main()```
```{```
``` int n;```
``` cin>>n;```
```int i=1;```
```while(i<=n)```
``` {```
``` int j=1;```
```while(j<=n)```
```{```
```cout<```j++;```
```}```
```i++;```
```cout<```}```
```return 0;```
```}```|

|

[Patterns4](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns4.cpp)

|

[CODE](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns4.cpp)

|
|---|---|
| `CUSTOM EXAMPLES` `INPUT` `OUTPUT` 4 4321 4321 4321 4321 |```#include ```
```using namespace std;```
```int main()```
```{```
``` int n;```
``` cin>>n;```
```int i=1;```
```while(i<=n)```
``` {```
``` int j=1;```
```while(j<=n)```
```{```
```cout<<(n-j+1);```
```j++;```
```}```
```i++;```
```cout<```}```
```return 0;```
```}```|

|

[Patterns5](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns5.cpp)

|

[CODE](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns5.cpp)

|
|---|---|
| `CUSTOM EXAMPLES` `INPUT` `OUTPUT` 4 1 12 123 1234 |```#include ```
```using namespace std;```
```int main()```
```{```
``` int n;```
``` cin>>n;```
```int i=1;```
```while(i<=n)```
``` {```
``` int j=1;```
```while(j<=i)```
```{```
```cout<```j++;```
```}```
```i++;```
```cout<```}```
```return 0;```
```}```|

|

[Patterns6](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns6.cpp)

|

[CODE](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns6.cpp)

|
|---|---|
| `CUSTOM EXAMPLES` `INPUT` `OUTPUT` 4 1 12 123 1234 |```#include ```
```using namespace std;```
```int main()```
```{```
``` int n,p;```
``` cin>>n;```
```int i=1;```
```while(i<=n)```
``` {```
``` int j=1,p=i;```
```while(j<=i)```
```{```
```cout<

```j++;```
```p++;```
```}```
```i++;```
```cout<```}```
```return 0;```
```}```|

|

[Patterns7](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns7.cpp)

|

[CODE](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns7.cpp)

|
|---|---|
| `CUSTOM EXAMPLES` `INPUT` `OUTPUT` 4 1 23 456 78910 |```#include ```
```using namespace std;```
```int main()```
```{```
``` int n,p=1;```
``` cin>>n;```
```int i=1;```
```while(i<=n)```
``` {```
``` int j=1;```
```while(j<=i)```
```{```
```cout<

```j++;```
```p++;```
```}```
```i++;```
```cout<```}```
```return 0;```
```}```|

|

[Patterns8](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns8.cpp)

|

[CODE](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns8.cpp)

|
|---|---|
| `CUSTOM EXAMPLES` `INPUT` `OUTPUT` 4 ABCD ABCD ABCD ABCD |```#include ```
```using namespace std;```
```int main()```
```{```
``` int n;```
```char ch;```
```cin>>n;```
```int i=1;```
```while(i<=n)```
``` {```
```int j=1;```
```ch='A';```
```while(j<=n)```
```{```
```cout<```j++;```
```ch++;```
```}```
```i++;```
```cout<```}```
```return 0;```
```}```|

|

[Patterns9](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns9.cpp)

|

[CODE](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns9.cpp)

|
|---|---|
| `CUSTOM EXAMPLES` `INPUT` `OUTPUT` 4 ABCD BCDE CDEF DEFG |```#include ```
```using namespace std;```
```int main()```
```{```
``` int n;```
```char ch;```
```cin>>n;```
```int i=1;```
```while(i<=n)```
``` {```
```int j=1;```
```ch='A'+i-1;```
```while(j<=n)```
```{```
```cout<```j++;```
```ch++;```
```}```
```i++;```
```cout<```}```
```return 0;```
```}```|

|

[Patterns10](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns10.cpp)

|

[CODE](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns10.cpp)

|
|---|---|
| `CUSTOM EXAMPLES` `INPUT` `OUTPUT` 4 A BB CCC DDDD |```#include ```
```using namespace std;```
```int main()```
```{```
``` int n;```
```char ch;```
```cin>>n;```
```int i=1;```
```while(i<=n)```
``` {```
```int j=1;```
```ch='A'+i-1;```
```while(j<=i)```
```{```
```cout<```j++;```
```}```
```i++;```
```cout<```}```
```return 0;```
```}```|

|

[Patterns11](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns11.cpp)

|

[CODE](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns11.cpp)

|
|---|---|
| `CUSTOM EXAMPLES` `INPUT` `OUTPUT` 4 A BC DEF GHIJ |```#include ```
```using namespace std;```
```int main()```
```{```
``` int n;```
```char ch='A';```
```cin>>n;```
```int i=1;```
```while(i<=n)```
``` {```
```int j=1;```
```while(j<=i)```
```{```
```cout<```j++;```
```ch++;```
```}```
```i++;```
```cout<```}```
```return 0;```
```}```|

|

[Patterns12](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns12.cpp)

|

[CODE](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns12.cpp)

|
|---|---|
| `CUSTOM EXAMPLES` `INPUT` `OUTPUT` 4 D CD BCD ABCD |```#include ```
```using namespace std;```
```int main()```
```{```
``` int n;```
```char ch;```
```cin>>n;```
```int i=1;```
```while(i<=n)```
``` {```
```int j=1;```
```ch='A'+n-i;```
```while(j<=i)```
```{```
```cout<```j++;```
```ch++;```
```}```
```i++;```
```cout<```}```
```return 0;```
```}```|

|

[Patterns13](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns13.cpp)

|

[CODE](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns13.cpp)

|
|---|---|
| `CUSTOM EXAMPLES` `INPUT` `OUTPUT` 4       *     **   *** **** |```#include ```
```using namespace std;```
```int main()```
```{```
```int n;```
```cin>>n;```
```int i=1;```
```while(i<=n)```
```{```
```int j=1;```
```while(j<=(n-i))```
```{```
```cout<<' ';```
```j++;```
```}```
```int k=1;```
```while(k<=i)```
```{```
```cout<<'*';```
```k++;```
```}```
```i++;```
```cout<```}```
```return 0;```
```}```|

|

[Patterns14](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns14.cpp)

|

[CODE](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns14.cpp)

|
|---|---|
| `CUSTOM EXAMPLES` `INPUT` `OUTPUT` 4 **** *** ** * |```#include ```
```using namespace std;```
```int main()```
```{```
```int n;```
```cin>>n;```
```int i=1;```
```while(i<=n)```
```{```
```int j=i;```
```while(j<=n)```
```{```
```cout<<'*';```
```j++;```
```}```
```i++;```
```cout<```}```
```return 0;```
```}```|

|

[Patterns15](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns15.cpp)

|

[CODE](https://github.com/ArshdeepSahni/CPP/blob/master/Patterns15.cpp)

|
|---|---|
| `CUSTOM EXAMPLES` `INPUT` `OUTPUT` 4       1     121   12321 1234321 |```#include ```
```using namespace std;```
```int main()```
```{```
```int n;```
```cin>>n;```
```int i=1;```
```while(i<=n)```
```{```
```int j=1;```
```while(j<=(n-i))```
```{```
```cout<<' ';```
```j++;```
```}```
```int k=1;```
```while(k<=i)```
```{```
```cout<```k++;```
```}```
```int p=k-2;```
```while(p>0)```
```{```
```cout<

```p--;```
```}```
```i++;```
```cout<```}```
```return 0;```
```}```|

|

[Binary Sort](https://github.com/ArshdeepSahni/CPP/blob/master/BinarySort.cpp)

|

[CODE](https://github.com/ArshdeepSahni/CPP/blob/master/BinarySort.cpp)

|
|---|---|
| `CUSTOM EXAMPLES` `INPUT` `OUTPUT` 4 (no. of Testcases) 1 2 2 3 3 5 2 (no. of elements to search) 3 5 |```#include ```
```using namespace std;```
```int main()```
```{```
```int n,a[100];```
```cin>>n;```
```int i=0;```
```while(i```{```
```cin>>a[i];```
```i++;```
```}```
```int t,b[t];```
```cin>>t;```
```i=0;```
```while(i```{```
```cin>>b[i];```
```i++;```
```}```
```int s=0,e=n-1,m=(s+e)/2;```
```i=0;```
```for(i=0;i<=t;i++){```
```s=0;e=n-1;m=(s+e)/2;```
```while(s<=e)```
```{```
```if(b[i]==a[m])```
```{```
```cout<```break;```
```}```
```else if(b[i]>a[m])```
```{```
```s=m++;```
```}```
```else{```
```e=m--;```
```}```
```}```
```}```
```return 0;```
```}```|