|
|
back to boardWA#8 plz somebody help me,its driving me insane Posted by cena 30 Nov 2012 14:43 here's my code,what's wrong with it,i get WA on test#8. #include <iostream> using namespace std; int main(){ char str[1000]; int sum = 0; for(int i = 0; str[i] != '\0'; ++i){ if(str[i] >= 'a' && str[i] <= 'z'){ sum += (str[i] - 97) % 3 + 1; }else if(str[i] == ' ' || str[i] == '.'){ ++sum;
}else if(str[i] == '!'){ sum += 3; }else if(str[i] == ','){ sum += 2; } } cout << sum; return 0; } Re: WA#8 plz somebody help me,its driving me insane char str[1002]; |
|
|