Skip to content

Commit dd9e499

Browse files
authored
Added some methods in sorting and updated info of some headers
I added another method by which we can sort the array in desc order using the reverse iterator , added how to sort only a part of the vector, and also updated the info about some headers
1 parent 5f3f65c commit dd9e499

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

cpp.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ Pointer is a variable which holds the memory information(address) of another var
256256
257257
```c
258258
datatype *pointername;
259+
(or)
260+
datatype* pointername;
259261
```
260262
### Example
261263
```c
@@ -546,6 +548,13 @@ v = {3,2,1};
546548

547549
sort(v.begin(), v.end()); // sorting in the vector in ascending order
548550
sort(v.begin(), v.end(), greater<int>()); // sorting in the vector in descending order
551+
//For sorting the vector in descending order, you could also use the reverse iterator
552+
//i.e.:
553+
sort(v.rbegin(),v.rend()); // This will also sort the vector in a descending order
554+
555+
//for sorting only a part of the vector , we can do:
556+
//sort(v.begin()+start_index,v.begin()+ending_index);
557+
//This will sort only part of the array from start_index to end_index
549558

550559
}
551560

@@ -558,10 +567,10 @@ sort(v.begin(), v.end(), greater<int>()); // sorting in the vector in descending
558567
|#include<string.h> | It is used to perform various string operations|
559568
|#include<math.h> | It is used to perform mathematical operations|
560569
|#include<iomanip.h> | It is used to access set() and setprecision()|
561-
|#include<signal.h> | It is used to perform signal handling functions like sign|
570+
|#include<signal.h> | It is used to perform signal handling functions like signal() and raise()|
562571
|#include<stdarg.h> | It is used to perform standard argument functions|
563572
|#include<errno.h> | It is used to perform error handling operations like errno|
564573
|#include<fstream.h> | It is used to control the data to read from a file|
565574
|#include<time.h> | It is used to perform functions related to date() and time|
566575
|#include<graphics.h> | It is used include and facilitate graphical operations in program|
567-
|#include<bits/stdc++.h> | It is used to include all the standard library files|
576+
|#include<bits/stdc++.h> | It is used to include all the standard library files, this is called a NON-STANDARD header file (it can't be compiled on a compiler other than GCC)|

0 commit comments

Comments
 (0)