SlideShare a Scribd company logo
1 of 24
 
A  lil  Bit  About  Templates  B4  V  Begin So, What Are They ??? ,[object Object],[object Object],[object Object],[object Object],[object Object]
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 , ''); Use this to read a whole  line  of text from the input file
[object Object]
Find Simplest way to find a substring What Does It Do ? ,[object Object],[object Object],string a=“hello world”; cout<<a.find(“0 w”);
Replace An Easy Way To Replace Text In Strings What Does It Do ? ,[object Object],string a=“hello world”; cout<<a.replace(i,j,”hi”);
Other  Useful  String  Functions ,[object Object],[object Object],[object Object],[object Object],[object Object]
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 !!!
[object Object]
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 , ‘’); (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
[object Object]
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()
[object Object],[object Object]
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

Similar to An approach to Programming Contests with C++

Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
Andrea Telatin
 
String and string manipulation
String and string manipulationString and string manipulation
String and string manipulation
Shahjahan Samoon
 
String and string manipulation x
String and string manipulation xString and string manipulation x
String and string manipulation x
Shahjahan Samoon
 

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

Strings v.1.1
Strings v.1.1Strings v.1.1
Strings v.1.1
 
Embed--Basic PERL XS
Embed--Basic PERL XSEmbed--Basic PERL XS
Embed--Basic PERL XS
 
3 character strings and formatted input output
3  character strings and formatted input output3  character strings and formatted input output
3 character strings and formatted input output
 
9 character string &amp; string library
9  character string &amp; string library9  character string &amp; string library
9 character string &amp; string library
 
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
 
introduction to strings in c programming
introduction to strings in c programmingintroduction to strings in c programming
introduction to strings in c programming
 
Team 1
Team 1Team 1
Team 1
 
Strings in C language
Strings in C languageStrings in C language
Strings in C language
 
String
StringString
String
 
Qt Translations
Qt TranslationsQt Translations
Qt Translations
 
Learning Ruby
Learning RubyLearning Ruby
Learning Ruby
 
String and string manipulation
String and string manipulationString and string manipulation
String and string manipulation
 
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
 
Ch09
Ch09Ch09
Ch09
 
2 data and c
2 data and c2 data and c
2 data and c
 
String and string manipulation x
String and string manipulation xString and string manipulation x
String and string manipulation x
 
Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programming
 
Module-2_Strings concepts in c programming
Module-2_Strings concepts in c programmingModule-2_Strings concepts in c programming
Module-2_Strings concepts in c programming
 
M C6java7
M C6java7M C6java7
M C6java7
 
Operation on string presentation
Operation on string presentationOperation on string presentation
Operation on string presentation
 

More from VNIT-ACM Student Chapter

More from VNIT-ACM Student Chapter (12)

An introduction to Reverse Engineering
An introduction to Reverse EngineeringAn introduction to Reverse Engineering
An introduction to Reverse Engineering
 
Introduction to the OSI 7 layer model and Data Link Layer
Introduction to the OSI 7 layer model and Data Link LayerIntroduction to the OSI 7 layer model and Data Link Layer
Introduction to the OSI 7 layer model and Data Link Layer
 
Research Opportunities in the United States
Research Opportunities in the United StatesResearch Opportunities in the United States
Research Opportunities in the United States
 
How web searching engines work
How web searching engines workHow web searching engines work
How web searching engines work
 
Research Opportunities in India & Keyword Search Over Dynamic Categorized Inf...
Research Opportunities in India & Keyword Search Over Dynamic Categorized Inf...Research Opportunities in India & Keyword Search Over Dynamic Categorized Inf...
Research Opportunities in India & Keyword Search Over Dynamic Categorized Inf...
 
Hadoop Map Reduce
Hadoop Map ReduceHadoop Map Reduce
Hadoop Map Reduce
 
Web Designing
Web DesigningWeb Designing
Web Designing
 
Inaugural Session
Inaugural SessionInaugural Session
Inaugural Session
 
Hacking - Web based attacks
Hacking - Web based attacksHacking - Web based attacks
Hacking - Web based attacks
 
Computers and Algorithms - What can they do and what can they not?
Computers and Algorithms - What can they do and what can they not?Computers and Algorithms - What can they do and what can they not?
Computers and Algorithms - What can they do and what can they not?
 
Foundations of Programming Part II
Foundations of Programming Part IIFoundations of Programming Part II
Foundations of Programming Part II
 
Foundations of Programming Part I
Foundations of Programming Part IFoundations of Programming Part I
Foundations of Programming Part I
 

Recently uploaded

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 

An approach to Programming Contests with C++

  • 1.  
  • 2.
  • 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 , ''); Use this to read a whole line of text from the input file
  • 5.
  • 6.
  • 7.
  • 8.
  • 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 !!!
  • 11.
  • 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 , ‘’); (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
  • 18.
  • 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.
  • 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()