
please wait
#include <iostream> #include <string> using namespace std; string input; int omregn (string r){ int i; int nyr[r.length()-1]; for (i=0;i<r.length();++i) { if (r[i] == ("x"||"X")){ nyr [i] = 10; } if (r[i] == ("v"||"V")) { nyr[i] = 5; } if (r[i] == ("i"||"I")) { nyr[i] = 1; } } return (nyr); } int main() { cin>>input; cout<< omregn (input); } |
|
|
r[i]=='x' || r[i]=='X'
becouse r[i]==('x'||'X')
compares char with a boolint
function cant return int[]
and I dont understand why do you need that array. Try changing int nyr[r.length()-1]
to int nyr
and nyr[i]==
to nyr+=
.r[i]=='x' || r[i]=='X' |
|
|