Академический Документы
Профессиональный Документы
Культура Документы
Afinitesetofinstructionsthatoperateson input(s)andresultsinoutput(s).
Whatdoweusethemfor?
ProgrammingLanguages?
Whatshouldyouuse?
DataStructures
Structuresthatareusedtostoredata
Why?
WhyC++/Python?
C++
Python
Skills?
Problemformat
Problemstatement
Problemexample(mightbethereornot)
Sampleinputandoutput
Stuffyoushouldknow
ForlargeNdonotuse(N>1,000,000),
ForsmallerN
Thingstokeepinmind
if,for,while,do...etcarethesamefromJava. Conceptsaredifferent,
OOPsupportisnotthere,butyoucanwriteOOPprogramswithit. Datatypesincludeprimitivesandstructs
Primitives
Structs
SampleCsnippet
structday{ unsignedshortyear; unsignedcharmonth; unsignedcharday; }; structstudent{ charname[256]; structdaybirthday; };
SampleCprogram
#include<stdio.h> intmain(){ inti; printf(Enteranumber\n); scanf(%d,&i); printf(Youentered%d\n,i); return0; }
Pointers
inti=90; int*iptr=&i; Youshouldalwayspointtoanaddressthatbelongstoyour process(orsharedwithyourprocess)andanaddressthat youaresurethatitisinitialized.
Pointersandarrays
Basics
Alittlebitadvanced
Definedlike:int*arr[N] Thedatatype:int(*aptr)[N]
Pointertomultidimentional array
intarr[N][M]; int(*aptr)[M]=arr;
Pointerstopointers
char*names[3]={name1,name2,name2}; char**ptr_array_start=names; inty; for(y=0;y<3;y++){ printf("%s\n",*(ptr_array_start++)); }
Functionprototypes
//mainfunctioncanbehere,ifsomainneedsafunction //prototypeforaddtocallit //validprototypes:add(int,int);add(inta,intb); intadd(inta,intb){ returna+b; } //maincanbehere,ifsomaincancalladdwithouta //prototype
Pointerstofunctions
intadd(inta,intb);//prototype int(*add)(inta,intb);//pointertotheaboveprototype
Definitions&Headerfiles
CStandardLibrary
string.h
Thestandardlibraryheaderfilewiththedefinitionsfor stringbasedfunctions
stdlib.h
Includesstandardfunctions
malloc
C++
SupportsOOP
StandardTemplateLibrary
Streams
SampleC++program
#include<iostream> intmain(){ inti; std::cout<<Enteranumber\n; std::cin>>i; std::cout<<Youentered<<i<<std::endl; return0; }
Usingstd
#include<iostream> usingnamespacestd; intmain(){ inti; cout<<Enteranumber\n; cin>>i; cout<<Youentered<<i<<endl; return0; }
Usingstd
#include<iostream> usingnamespacestd; intmain(){ inti; cout<<Enteranumber\n; cin>>i; cout<<Youentered<<i<<endl; return0; }
STL
Additionalstuff
SampleproblemI
http://code.google.com/codejam/contest/619102/dashboard#s=p0
SampleProblemII
http://code.google.com/codejam/contest/90101/dashboard#s=p0
SampleProblemIII
Problem15fromIEEExtreme2011
SampleProblemIII
Problem15fromIEEExtreme2011