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呢。。。。#include <iostream> #include <string.h> using namespace std; int main () { int flag[7],len,i; int num[20]; char a[20]; while(cin.getline(a,20)) { len=strlen(a); memset(flag,0,sizeof(flag)); memset(num,0,sizeof(num)); for (i=0;i<len;i++) { if (a[i]=='B'||a[i]=='F'||a[i]=='P'||a[i]=='V') {if (flag[1]==0) {num[i]=1;flag[1]=1;}else continue;} if (a[i]=='C'||a[i]=='G'||a[i]=='J'||a[i]=='K'||a[i]=='Q'||a[i]=='X'||a[i]=='S'||a[i]=='Z') {if (flag[2]==0) {num[i]=2;flag[2]=1;}else continue;} if (a[i]=='D'||a[i]=='T') {if (flag[3]==0) {num[i]=3;flag[3]=1;}else continue;} if (a[i]=='L') {if (flag[4]==0) {num[i]=4;flag[4]=1;}else continue;} if (a[i]=='M'||a[i]=='N') {if (flag[5]==0) {num[i]=5;flag[5]=1;}else continue;} if (a[i]=='R') {if (flag[6]==0) {num[i]=6;flag[6]=1;}else continue;} if (a[i]=='A'||a[i]=='E'||a[i]=='I'||a[i]=='O'||a[i]=='U'||a[i]=='H'||a[i]=='W'||a[i]=='Y') {memset(flag,0,sizeof(flag));continue;} } for (i=0;i<len;i++) { if (num[i]!=0) {cout<<num[i];} else continue; } 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