Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Problem pri kompajliranju

[es] :: C/C++ programiranje :: C/C++ za početnike :: Problem pri kompajliranju

[ Pregleda: 1788 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

ProgramerVL
Srbija

Član broj: 329358
Poruke: 13



+1 Profil

icon Problem pri kompajliranju10.08.2016. u 16:05 - pre 92 meseci
Zašto ovaj kod ne neće da se kompajlira?
Code (cpp):

#include <bits/stdc++.h>
using namespace std;

map<int, int> fib;
fib[0] = 0;
fib[1] = 1;

int getFib(int i) {
    if (fib.find(i) != fib.end()) {
        return fib[i];
    }
    fib[i] = getFib(i-1) + getFib(i-2);
    return fib[i];

}
int main() {
   
    int i;
    cin >> i;
    cout << getFib(i);
    return 0;
}
 

A ovaj hoće?
Code (cpp):
#include <bits/stdc++.h>
using namespace std;

map<int, int> fib;


int getFib(int i) {
    if (fib.find(i) != fib.end()) {
        return fib[i];
    }
    fib[i] = getFib(i-1) + getFib(i-2);
    return fib[i];

}
int main() {
    fib[0] = 0;
    fib[1] = 1;    
    int i;
    cin >> i;
    cout << getFib(i);
    return 0;
}
 
 
Odgovor na temu

Branimir Maksimovic

Član broj: 64947
Poruke: 5534
109.72.51.248



+1064 Profil

icon Re: Problem pri kompajliranju10.08.2016. u 22:35 - pre 92 meseci
Ne možeš da stavljaš kod van funkcija. I heder ti nije standardni . <map> je header koji ti treba... i <iostream>
 
Odgovor na temu

ProgramerVL
Srbija

Član broj: 329358
Poruke: 13



+1 Profil

icon Re: Problem pri kompajliranju11.08.2016. u 22:47 - pre 92 meseci
hvala
 
Odgovor na temu

[es] :: C/C++ programiranje :: C/C++ za početnike :: Problem pri kompajliranju

[ Pregleda: 1788 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.