

C++ Funkce
Ahoj, zacal jsem se samoucit c++ chtel jsem zkusit napsat takovou easy textovou hru, ale narazil jsem na problem.
Mam kod a potreboval bych aby mi ta funkce returnovala hodnotu toho utoku(int utok) do main, a nevim jak to mam udelat. Kdyby jste mi stim nekdo poradil, byl bych vam moc vdecnej.
#include <iostream>
#include <string>
#include <ctime>
using namespace std;
int zbran=1; //1=drevena, 2=zelezna, 3=kamenna
int utok; //Odvíji se od nej sila utoku
int zautoc(){
cout<<"Co chcete udelat? Vypad /V/, Bodnout /B/, Seknout /S/"<<endl;
char vyber;
cin>>vyber;
if(zbran==1){ //zjisteni druhu zbrane
switch(vyber){ //vyber utoku
case 'V':{
utok=(rand() %18)+1; //vypad
return utok;}
case 'B':{
utok=(rand() %20)+1; //bodnuti
return utok;}
case 'S':{
utok=(rand() %10)+1; //seknuti
return utok;}
}
}
if(zbran==2){
switch(vyber){
case 'V':{
utok=(rand()% 23)+1;
return utok;}
case 'B':{
utok=(rand()% 20)+1;
return utok;}
case 'S':{
utok=(rand()% 17)+1;
return utok;}
}
}
if(zbran=3){
switch(vyber){
case 'V':{
utok=(rand()% 8)+1;
return utok;
}
case 'B':{
utok=(rand()% 10)+1;
return utok;
}
case 'S':{
utok=(rand()% 17)+1;
return utok;
}
}
}
}
int main(){
zautoc();
cout<<utok<<endl;
system("pause");
return 0;
}
int utok = zautoc();
Diky