Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
明明可以的啊!!!倒底错在哪啊?老是WA!~有什么测试数据吗????!!!!!帮帮忙啊!//acm 2608 //Soundex #include <iostream> #include <cstring> using namespace std; const int size = 20; int main() { char word[size]; int last = 0; enum {n1=1 , n2 , n3 , n4 , n5 , n6}; while(cin>>word) { int k=(strlen(word) >= size ? size : strlen(word)); for(int j=0 ; j < k ; j++) { switch(*(word + j)) { case 'B': case 'F': case 'P': case 'V': { if(last != n1) { last = n1; cout<<n1; } break; } case 'C': case 'G': case 'J': case 'K': case 'Q': case 'S': case 'X': case 'Z': { if(last != n2) { last = n2; cout<<n2; } break; } case 'D': case 'T': { if(last != n3) { last = n3; cout<<n3; } break; } case 'L': { if(last != n4) { last = n4; cout<<n4; } break; } case 'M': case 'N': { if(last != n5) { last = n5; cout<<n5; } break; } case 'R': { if(last != n6) { last = n6; cout<<n6; } break; } default: last = 0; } } cout<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator