Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

#include <bits/stdc++.

h> - ukljucuje sve biblioteke

sort(v.begin(),v.end()) - sortira u rasucem poredku


sort(v.rbegin(),v.rend()) - sortira u opadajucem poredku

char(toupper('c')) za dobijanje velikog slova iz malog


char(tolower('c')) za dobijanje malog slova iz velikog

set<int> a;
a.insert(10);
a.erase(50);
a.size();

set<int, greater<int> > a ; - sortiran set


a.insert(b.begin(), b.end());
*next(my_set.begin(), n); - za dobijanje n-tog bropja seta

find()

accumulate(a.begin(), a.end(), 0) - za nalazenje sume vektora

rijec.substr(odakle pocinje, koliko slova uzima)

*max_element(b.begin(), b.end());

int memo[10000] = {0}; - stavlja sve elemente na 0

int(ch) - 48 - za dobijanje broja iz chara

stoi(str) - pretvara string u int

pair<string , int> p1 = make_pair("Testing" , 123)


p1.first - prvi element i p1.second - drugi

KURS
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
------------------------

Unosenje velikih brojeva na najbrzi nacin

void fastscan(int &number)


{
//variable to indicate sign of input number
bool negative = false;
register int c;

number = 0;

// extract current character from buffer


c = getchar();
if (c=='-')
{
// number is negative
negative = true;

// extract the next character from the buffer


c = getchar();
}

// Keep on extracting characters if they are integers


// i.e ASCII Value lies from '0'(48) to '9' (57)
for (; (c>47 && c<58); c=getchar())
number = number *10 + c - 48;

// if scanned input has a negative sign, negate the


// value of the input number
if (negative)
number *= -1;
}

// Function Call
int main()
{
int number;
fastscan(number);
cout << number << "\n";
return 0;
}

-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------

Strukture

vector

.begin() – Returns an iterator pointing to the first element in the vector


.end() – Returns an iterator pointing to the theoretical element that follows the
last element in the vector
.rbegin() – Returns a reverse iterator pointing to the last element in the vector
(reverse beginning). It moves from last to first element
.rend() – Returns a reverse iterator pointing to the theoretical element preceding
the first element in the vector (considered as reverse end)

for (auto i = g1.begin(); i != g1.end(); ++i) - ispisivanje vektora


pomocu iteratora
cout << *i << " ";

.push_front()
.erase()
.insert()

You might also like