|
|
вернуться в форумTest #5? Whats wrong with my code? #include <iostream> #include <string> using namespace std; int main() { int a[1000]; int n,i,k; char Name; cin>>n; string B; k=0; for (i=0;i<n;i++){ cin>>B; Name=B[0]; if(Name=='A' or Name=='P' or Name=='O' or Name=='R') {a[i]=1;} else {if(Name=='B' or Name=='M' or Name=='S') {a[i]=2;} else {a[i]=3;}; } } k=a[0]-1;
for (i=1;i<n;i++){ if (a[i-i]<a[i]){ k=k+a[i]-a[i-1];} else { k=k+a[i-1]-a[i];}
} cout<<k; return 0;
} |
|
|