SlideShare a Scribd company logo
 
A  lil  Bit  About  Templates  B4  V  Begin So, What Are They ??? It Aids Generic Programming    ( Basically, Makes Life Much Easier ) You Can Create a Queue Of  Type T  where, T is of any type !!! Eg.  queue<int> iq; queue<string> sq;
File Handling Handling Input, Output From Files Is  Much Easier Than You Think !!! freopen(“input file name”,”r”,stdin); freopen(“output file name”,”w”,stdout);
-  TIP  - string s; getline(cin , s , '\n'); Use this to read a whole  line  of text from the input file
A world of strings
Find Simplest way to find a substring What Does It Do ? Returns The Index Of  The First  Occurrence Of  The Substring. If  There Is No Such Occurrence,  returns a value > Length Of String. string a=“hello world”; cout<<a.find(“0 w”);
Replace An Easy Way To Replace Text In Strings What Does It Do ? Replaces Some Particular Text In A  String With The Text You Want  To Replace With string a=“hello world”; cout<<a.replace(i,j,”hi”);
Other  Useful  String  Functions string s=“01236789876543210”;  s.insert(i,”45”); s.erase(i,j); s.length(); s.rfind(“3”);
Extract  Data  From  A  String  With  sscanf() It is like scanf() but, scans from a string instead of standard input !!! string s=“12:40”; int h,m; sscanf(s.c_str() , &quot;%d:%d“ , &h , &m); cout<<h<<endl<<m;
-  TIP  - You can use find and replace together, to replace all occurences of a particular substring in a string, with some other sequence of characters, irrespective of the size of the new sequence of characters ! Very Useful !!!
#include<sstream>
Converting  Anything   Printable,  To  A  String Not as hard as it sounds !! stringstream ss; string s; float f=1.732; int i=43; char c=‘g’; ss<<“StringstreamsRock!!”<<f<<i<<c; ss>>s; cout<<s;
-  TIP  - It Is A Better Idea To Use-- getline(ss , s , ‘\n’); (or) s=ss.str();
 
a^=b^=a^=b; What Does It Do ?? Guesses Permitted !!
a=a^b; b=a^b; a=a^b; After  Simplifying  It  A  Little  Bit
It  Works  Coz  Of  The  Fact  That: a^b=c => b^c=a  c^a=b
#include<vector>
Capabilities: Easy Sorting!! Constant Access Time!! Linear Time for finding elements!!
So why not Arrays?? Variable Size!!
Useful Functions: push_back() pop_back() insert() erase() clear() assign()
Ready to use Algorithms   #include<algorithm>
C++ Already Contains:  (Used with respect to  Vector v1) sort()  stable_sort() qsort() find() reverse() merge()
There’s More.. min_element() max_element() next_permutation() prev_permutation()

More Related Content

PDF
Constructs and techniques and their implementation in different languages
PDF
Shortcuts JAVA
PDF
Bash is Testing
PDF
Type Systems on the example of TypeScript
PDF
Lambda Expressions: Myths and Mistakes - Richard Warburton (jClarity)
PPTX
Do..while presentation
PPTX
товчин тэмдэгт (Button symbol) ийг үүсгэх
PPTX
файл, файлын оролт гаралт
Constructs and techniques and their implementation in different languages
Shortcuts JAVA
Bash is Testing
Type Systems on the example of TypeScript
Lambda Expressions: Myths and Mistakes - Richard Warburton (jClarity)
Do..while presentation
товчин тэмдэгт (Button symbol) ийг үүсгэх
файл, файлын оролт гаралт

Similar to An approach to Programming Contests with C++ (20)

PPT
Strings v.1.1
ODP
Embed--Basic PERL XS
PDF
3 character strings and formatted input output
PDF
9 character string &amp; string library
PDF
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
PPTX
introduction to strings in c programming
PPTX
Strings in C language
PDF
String
PPTX
Qt Translations
PPT
Learning Ruby
PPT
String and string manipulation
PDF
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
PDF
2 data and c
PPSX
String and string manipulation x
PPTX
Handling of character strings C programming
PPTX
Module-2_Strings concepts in c programming
PPT
M C6java7
PPT
Operation on string presentation
Strings v.1.1
Embed--Basic PERL XS
3 character strings and formatted input output
9 character string &amp; string library
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
introduction to strings in c programming
Strings in C language
String
Qt Translations
Learning Ruby
String and string manipulation
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
2 data and c
String and string manipulation x
Handling of character strings C programming
Module-2_Strings concepts in c programming
M C6java7
Operation on string presentation
Ad

More from VNIT-ACM Student Chapter (12)

PPS
An introduction to Reverse Engineering
PPS
Introduction to the OSI 7 layer model and Data Link Layer
PPTX
Research Opportunities in the United States
PPS
How web searching engines work
PPS
Research Opportunities in India & Keyword Search Over Dynamic Categorized Inf...
PPT
Hadoop Map Reduce
PPS
PPS
Inaugural Session
PPS
Hacking - Web based attacks
PPS
Computers and Algorithms - What can they do and what can they not?
PPS
Foundations of Programming Part II
PPS
Foundations of Programming Part I
An introduction to Reverse Engineering
Introduction to the OSI 7 layer model and Data Link Layer
Research Opportunities in the United States
How web searching engines work
Research Opportunities in India & Keyword Search Over Dynamic Categorized Inf...
Hadoop Map Reduce
Inaugural Session
Hacking - Web based attacks
Computers and Algorithms - What can they do and what can they not?
Foundations of Programming Part II
Foundations of Programming Part I
Ad

Recently uploaded (20)

PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Lesson notes of climatology university.
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Insiders guide to clinical Medicine.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
Cell Structure & Organelles in detailed.
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Pharma ospi slides which help in ospi learning
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
RMMM.pdf make it easy to upload and study
102 student loan defaulters named and shamed – Is someone you know on the list?
VCE English Exam - Section C Student Revision Booklet
Microbial diseases, their pathogenesis and prophylaxis
Computing-Curriculum for Schools in Ghana
Renaissance Architecture: A Journey from Faith to Humanism
STATICS OF THE RIGID BODIES Hibbelers.pdf
Basic Mud Logging Guide for educational purpose
Lesson notes of climatology university.
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Insiders guide to clinical Medicine.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Sports Quiz easy sports quiz sports quiz
Cell Structure & Organelles in detailed.
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Pharma ospi slides which help in ospi learning
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Final Presentation General Medicine 03-08-2024.pptx
RMMM.pdf make it easy to upload and study

An approach to Programming Contests with C++

  • 1.  
  • 2. A lil Bit About Templates B4 V Begin So, What Are They ??? It Aids Generic Programming  ( Basically, Makes Life Much Easier ) You Can Create a Queue Of Type T where, T is of any type !!! Eg. queue<int> iq; queue<string> sq;
  • 3. File Handling Handling Input, Output From Files Is Much Easier Than You Think !!! freopen(“input file name”,”r”,stdin); freopen(“output file name”,”w”,stdout);
  • 4. - TIP - string s; getline(cin , s , '\n'); Use this to read a whole line of text from the input file
  • 5. A world of strings
  • 6. Find Simplest way to find a substring What Does It Do ? Returns The Index Of The First Occurrence Of The Substring. If There Is No Such Occurrence, returns a value > Length Of String. string a=“hello world”; cout<<a.find(“0 w”);
  • 7. Replace An Easy Way To Replace Text In Strings What Does It Do ? Replaces Some Particular Text In A String With The Text You Want To Replace With string a=“hello world”; cout<<a.replace(i,j,”hi”);
  • 8. Other Useful String Functions string s=“01236789876543210”; s.insert(i,”45”); s.erase(i,j); s.length(); s.rfind(“3”);
  • 9. Extract Data From A String With sscanf() It is like scanf() but, scans from a string instead of standard input !!! string s=“12:40”; int h,m; sscanf(s.c_str() , &quot;%d:%d“ , &h , &m); cout<<h<<endl<<m;
  • 10. - TIP - You can use find and replace together, to replace all occurences of a particular substring in a string, with some other sequence of characters, irrespective of the size of the new sequence of characters ! Very Useful !!!
  • 12. Converting Anything Printable, To A String Not as hard as it sounds !! stringstream ss; string s; float f=1.732; int i=43; char c=‘g’; ss<<“StringstreamsRock!!”<<f<<i<<c; ss>>s; cout<<s;
  • 13. - TIP - It Is A Better Idea To Use-- getline(ss , s , ‘\n’); (or) s=ss.str();
  • 14.  
  • 15. a^=b^=a^=b; What Does It Do ?? Guesses Permitted !!
  • 16. a=a^b; b=a^b; a=a^b; After Simplifying It A Little Bit
  • 17. It Works Coz Of The Fact That: a^b=c => b^c=a c^a=b
  • 19. Capabilities: Easy Sorting!! Constant Access Time!! Linear Time for finding elements!!
  • 20. So why not Arrays?? Variable Size!!
  • 21. Useful Functions: push_back() pop_back() insert() erase() clear() assign()
  • 22. Ready to use Algorithms  #include<algorithm>
  • 23. C++ Already Contains: (Used with respect to Vector v1) sort() stable_sort() qsort() find() reverse() merge()
  • 24. There’s More.. min_element() max_element() next_permutation() prev_permutation()