求救~請問為什麼第三、四、五筆測資會試WA?
以下為程式碼:
#include<iostream>
#include<cmath>
#include<string.h>
using namespace std;
char text[10000010];
int s;
int name[10];
int bigger(int[]);
int maxi;
int main()
{
cin.getline(text,10000010);
memset(name,0,sizeof(name));
s=strlen(text);
for(int i=0; i<s; i++) //分組
{
if(text[i]=='a'|| text[i]=='A'||text[i]=='h'|| text[i]=='H'||text[i]=='o'|| text[i]=='O'||text[i]=='V'|| text[i]=='v')
name[0]+=1;
if(text[i]=='b'|| text[i]=='B'||text[i]=='i'|| text[i]=='I'||text[i]=='p'|| text[i]=='P'||text[i]=='W'|| text[i]=='w')
name[1]+=1;
if(text[i]=='c'|| text[i]=='C'||text[i]=='j'|| text[i]=='J'||text[i]=='q'|| text[i]=='Q'||text[i]=='X'|| text[i]=='x')
name[2]+=1;
if(text[i]=='d'|| text[i]=='D'||text[i]=='k'|| text[i]=='K'||text[i]=='r'|| text[i]=='R'||text[i]=='Y'|| text[i]=='y')
name[3]+=1;
if(text[i]=='e'|| text[i]=='E'||text[i]=='l'|| text[i]=='L'||text[i]=='s'|| text[i]=='S'||text[i]=='Z'|| text[i]=='z')
name[4]+=1;
if(text[i]=='f'|| text[i]=='F'||text[i]=='m'|| text[i]=='M'||text[i]=='t'|| text[i]=='T')
name[5]+=1;
if(text[i]=='g'|| text[i]=='G'||text[i]=='n'|| text[i]=='N'||text[i]=='u'|| text[i]=='U')
name[6]+=1;
}
maxi=0;
maxi=bigger(name); //接收函式回傳最大的值
if(maxi==name[0]) //判斷最大的值符合哪一個人
{
cout << "Saber" << endl;
}
else if(maxi==name[1])
{
cout << "Lancer" << endl;
}
else if(maxi==name[2])
{
cout << "Archer" << endl;
}
else if(maxi==name[3])
{
cout << "Rider" << endl;
}
else if(maxi==name[4])
{
cout << "Caster" << endl;
}
else if(maxi==name[5])
{
cout << "Assassin" << endl;
}
else if(maxi==name[6])
{
cout << "Berserker" << endl;
}
return 0;
}
int bigger(int nameyes[]) //找最大的值
{
int maxia=0;
for(int i=0; i<7; i++)
{
if(maxia<nameyes[i])
{
maxia=nameyes[i];
}
}
return maxia;
}