|
|
вернуться в форумWA #1 please help! Послано Freddy 30 май 2013 19:45 I don't understand where I'm wrong. I tried the sample and the result is right! #include<iostream> #include<map> using namespace std; int main() { int n,num; map<char,int> val; val['a']=1;val['b']=2;val['c']=3;val['d']=3;val['e']=3;val['f']=3;val['g']=2;val['h']=1; val['1']=1;val['2']=2;val['3']=3;val['4']=3;val['5']=3;val['6']=3;val['7']=2;val['8']=1; char xy[1]; cin>>n; while(n--) { cin>>xy; num=val[xy[0]]+val[xy[1]]; if(num==6) num+=2; if(num==5) num++; cout <<num<<endl; } } |
|
|